Results 1 to 5 of 5

Thread: no data - but data is there!

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: no data - but data is there!

    interesting...if i do a while datareader.read() - it works fine...

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: no data - but data is there!

    Yes, it's supposed to work that way.

    Btw, does your query return only 1 value?

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: no data - but data is there!

    yup it does

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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
  •  



Click Here to Expand Forum to Full Width