Results 1 to 4 of 4

Thread: database help....

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    database help....

    i am facing some kind of bug in my code i dont know.....i have the following code:
    VB Code:
    1. dim connection as new sqlConnection("<my connection string>")
    2. connection.open()
    3. dim command as sqlcommand = connection.createcommand()
    4. command.commandtext = "SELECT * FROM commentLog WHERE 'id' LIKE '2b5bd2c4-fb7d-487b-b299-044e6daf0008'"
    5. MessageBox.show(command.executereader()(0).ToString())
    i get the following error:
    Invalid attempt to read when no data is present.

    but if i try putting this code into the sql entreprise manager he returns me a line(the one i want to retrieve) so i dont get it how my code doesnt work and the sql entreprise manager does work.

    any help plz?
    \m/\m/

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Try this

    Code:
    dim connection as new sqlConnection("<my connection string>")
    connection.open()
    dim command as sqlcommand = connection.createcommand()
    command.commandtext = "SELECT * FROM commentLog WHERE id LIKE '2b5bd2c4-fb7d-487b-b299-044e6daf0008'"
    
    Dim rd As SqlClient.SqlDataReader
          
    rd = command.ExecuteReader(CommandBehavior.CloseConnection)
    rd.Read()
    MessageBox.Show(String.Format("{0}", rd.Item(0)))
    rd.Close()

  3. #3

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    ah! how dumb..it must be the Read() thing.......tks! ill try it now
    \m/\m/

  4. #4

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    yep worked
    u rox
    \m/\m/

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