View Full Version : ASP.Net Row Handle is Invalid (detailed)

07-22-2004, 10:20 PM
I'm getting "Row Handle is Invalid" error message while trying to filter an Access database records. Here is what happens - I have a Customer dropdown list. When I select all Transactions by a Customer, it works fine. But when I don't filter by a Customer and trying to get just All Transactions, then I get that error message. It all happens on the server. On my laptop I don't have any problems. Here is the completed code -

Private Sub btnFilter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFilter.Click
Dim rdr As OleDb.OleDbDataReader
Dim i As Integer, sSQL As String

'Name is not Transactions filed - I'll replace blanks with Customers Names later
sSQL = "Select '' As Name, Id1, Format(Date1,'dd-MMM-yyyy') As Tr_Date, Format(Amount, '$0.00') As Amount, RowNum from Transactions Where "

'if "(All)" selected from Dropdown then don't filter Transactions - and this is exactly when the error happens
If ddUser.SelectedItem.Text <> "(All)" Then _
sSQL &= "Id1 = " & ddUser.SelectedItem.Value & ""

If sSQL.EndsWith(" ") Then sSQL = sSQL.Substring(0, sSQL.Length - 7)
sSQL &= " Order By Date1"

'Get dataset (ds)
da = New OleDbDataAdapter(sSQL, ConnectionString)
Session("View") = ds.Tables(0).DefaultView
Session("SQL") = sSQL

'Replace blanks with Names from Customers table now
Dim dv As DataView = CType(Session("View"), DataView)
For i = 0 To dv.Count - 1
cmd.Connection = cnn
cmd.CommandText = "Select Name From Customers Where RowNum = " & dv.Item(i).Item(1)
rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
dv.Item(i).Item(0) = rdr(0)
Next i

Session("View") = dv

'Bind to Datagrid
dGr.DataSource = Session("View")
dGr.Visible = True
End Sub

Any ideas?