p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ADO.NET (http://p2p.wrox.com/forumdisplay.php?f=109)
-   -   Problem in SQL query (http://p2p.wrox.com/showthread.php?t=20927)

liorlankri November 7th, 2004 07:41 AM

Problem in SQL query
 
I have this Code

CommandText = "SELECT firstName FROM Students Where Students.ID
='"&idNum& "'"

myCommand = New SqlCommand(CommandText, myConnection)
Dim name As String = myCommand.ExecuteReader.GetString(0)
Response.Write(name)
myConnection.Close()



I get this Error massage:

Exception Details: System.InvalidOperationException: Invalid attempt to read when no data is present.







pradeep_itguy November 8th, 2004 12:37 AM

Check whether record exists before you start reading it.
i.e. before assigning the value check if it exists.

It is not how much we do,
but how much love we put in the doing.

-Mother Theresa


All times are GMT -4. The time now is 05:07 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.