no data exists for the row/column

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?
 
N

Norman Yuan

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

....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top