No data exists for row/column
I am using the examples in the book as an example to fit specific situations that I am working on using Visual Basic 2008.
In chapter 7 the ListView works perfectly and gives me what I want. When I select a specific record to view I get the "No data exists for row/column" error. My code in the ListView click event looks like this:
'Initialize a new instance of the databas class...
Using objData As New WDABase
Try
'get the specific record selected in the ListView control...
objData.SQL = "usp_SelectAnEmployee"
objData.InitializeCommand()
objData.AddParameter("@DisplayName", Data.OleDb.OleDbType.Char, _
50, lstvStaff.SelectedItems.Item(0).Text)
objData.OpenConnection()
objData.DataReader = objData.Command.ExecuteReader
'See if any data exists before continuing...
If objData.DataReader.HasRows Then
objData.DataReader.Read()
'Read the first and onlyrow of data...
objData.DataReader.Read()
'Clear prior values...
ClearAll()
'Populate the staff data controls...
>txtDisplayName.Text = objData.DataReader.Item("DisplayName")
txtFName.Text = objData.DataReader.Item("FName").ToString
txtLName.Text = objData.DataReader.Item("LName").ToString
txtDisplayName.Text = objData.DataReader.Item _
("DisplayName").ToString
End If
objData.DataReader.Close()
Catch ex As Exception
'MsgBox(ex.Message)
End Try
End Using
The program hangs on the line marked >
To verify that I am actually connected I placed a message box immediately before the line that hung. The message box contained this code MsgBox(objData.DataReader.FieldCount) and retur5ned the exact number of fields in the database.
I am at a loss as to how to find and correct this problem.
|