|
-
Apr 13th, 2005, 05:37 PM
#1
Thread Starter
PowerPoster
no data - but data is there!
hi there
using oledb here
i am doing a simple select statement. Data does exist if i look at the table myself or do a SQL query in MS Access where i am obtaining the data from however asp.net/vb.net reports there is no data recieved from the database - but that data is there.
any ideas?
Code:
Dim theCarIDStatement As String = "SELECT CarID FROM cars WHERE carManufacturer = '" + cmbCars.SelectedItem.Text + "'"
If cmbCarsModel.Items.Count <> 0 Then
theCarIDStatement += " AND carModel = '" + cmbCarsModel.SelectedItem.Text + "'"
End If
Dim CarIDoleDBQuery As New OleDbCommand(theCarIDStatement, theOLEDBConnection)
theOLEDBConnection.Open()
Dim theCarIDDataReader As OleDbDataReader = CarIDoleDBQuery.ExecuteReader()
Dim theCarID As Integer
theCarID = theCarIDDataReader.GetInt32(0) '<< HERE
-
Apr 13th, 2005, 05:52 PM
#2
Thread Starter
PowerPoster
Re: no data - but data is there!
interesting...if i do a while datareader.read() - it works fine...
-
Apr 14th, 2005, 06:03 AM
#3
Re: no data - but data is there!
Yes, it's supposed to work that way.
Btw, does your query return only 1 value?
-
Apr 14th, 2005, 07:00 AM
#4
Thread Starter
PowerPoster
Re: no data - but data is there!
-
Apr 14th, 2005, 07:48 AM
#5
Re: no data - but data is there!
Then use .ExecuteScalar(). It's more efficient.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|