no data exists for the row/column

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I run the following code:

objoledbcommand.Connection.Open()
strsql = "select first_name + ' ' + last_name as fullname from
tblperson where pers_entity_id = '" & ddlClient.SelectedValue & "'"
objoledbcommand.CommandText = strsql
objoledbdatareader = objoledbcommand.ExecuteReader
txtClient.Text = objoledbdatareader.Item("first_name")
objoledbcommand.Connection.Close()

and it errors on line "txtClient.Text = objoledbdatareader.item("fullname")
with
no data exists for the row/column.

I ran the exact same query in query analyzer with the correct id in the
where clause and one record is found.

on debug the strsql has all the items it needs in where clause

Any wisdom?
 
After the command returns you a DataReader, you have to read records from
database line by line:

....

objoledbdatareader = objoledbcommand.ExecuteReader

If objoledbdatareader.Read() Then
txtClient.Text = objoledbdatareader.Item("first_name")
End If

....
 
Back
Top