Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.††Topics such as question regarding the System.Data namespace are appropriate.††Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 7th, 2004, 07:41 AM
Authorized User
 
Join Date: Oct 2004
Location: , , Israel.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.






Reply With Quote
  #2 (permalink)  
Old November 8th, 2004, 12:37 AM
Friend of Wrox
 
Join Date: Feb 2004
Location: Bangalore, Karnataka, India.
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Query Problem mike.chary SQL Server 2005 1 September 26th, 2007 07:19 AM
SQL Query problem skarthikk SQL Server 2000 1 August 7th, 2006 03:20 AM
SQL query problem - Need Help Settt Biztalk 0 September 12th, 2005 10:32 AM
sql query problem Baby_programmer ASP.NET 1.0 and 1.1 Basics 1 October 14th, 2004 08:13 AM
Sql Query Problem mateenmohd SQL Language 0 January 13th, 2004 05:31 AM



All times are GMT -4. The time now is 09:29 AM.


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