How do I read a row with the odbcdataadapter without using a web control?

J

jm

I do not want to use the datagrid, datalist, etc. I want to retrieve
simply the value from the query.

I know the sql is returning data, because, if I use a grid, I can
populate it.

I have looked everywhere, but it won't work.

Dim resultsDataSet as New DataSet()
Dim myDataAdapter as odbcdataadapter
myDataAdapter = New odbcdataadapter(sqlLastID, conn)

'this works fine here
myDataAdapter.Fill(resultsDataSet)
order_id_grid.DataSource = resultsDataSet
order_id_grid.DataBind()

'this does not

temp = resultsDataSet.tables(0).rows("order_id").toString()

it complains that:

Input string was not in a correct format.

Thank you for any help. I cannot find the answer. The returning
value from the database is an integer. I have tried it with temp as a
string and an integer. Thanks again.
 
M

Michael

If filling the Dataset isn't really needed, you can use the ExecuteScalar()
Function of command object to return the first column of the first row.
Even if you do need the Dataset, you can still use the function, as it would
be more efficient than getting it out of the dataset.

temp = sqlLastID.ExecuteScalar()

HTH,
--Michael
 
M

Michael

fyi, the correct syntax would be

temp = resultsDataSet.tables(0).rows(0)("order_id")

You have to specify that you actually wanted the first row
 

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