|
-
Sep 13th, 2003, 04:08 PM
#1
Thread Starter
yay gay
database help....
i am facing some kind of bug in my code i dont know.....i have the following code:
VB 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'"
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/
-
Sep 13th, 2003, 05:41 PM
#2
Frenzied Member
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()
-
Sep 13th, 2003, 05:51 PM
#3
Thread Starter
yay gay
ah! how dumb..it must be the Read() thing.......tks! ill try it now
\m/  \m/
-
Sep 13th, 2003, 05:54 PM
#4
Thread Starter
yay gay
\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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|