944,146 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 10277
  • C# RSS
May 26th, 2005
0

Problem with sql reader

Expand Post »
Ok, I am trying to read data back from a database, when I build my program it throws an error saying: "No overload for method 'SqlDataReader' takes '0' arguments."

Here is the code from the program:
  
SqlDataReader existsRdr = new SqlDataReader();
existsRdr.Read();

Anyhelp would be great.
Thanks in advance.
Similar Threads
Reputation Points: 23
Solved Threads: 6
Posting Pro
Dark_Omen is offline Offline
573 posts
since Apr 2004
May 27th, 2005
0

Re: Problem with sql reader

You return a SqlDataReader as the result of the .ExecuteReader() method of the Command object:

C# Syntax (Toggle Plain Text)
  1. SqlConnection myConnection = new SqlConnection(myConnectionString);
  2. SqlCommand myCommand = new SqlCommand(mySelectQuery, myConnection);
  3. myConnection.Open();
  4. SqlDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
  5. while(myReader.Read())
  6. {
  7. Console.WriteLine(myReader.GetString(0));
  8. }
  9. myReader.Close();
  10. //Implicitly closes the connection because CommandBehavior.CloseConnection was specified.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
May 28th, 2005
0

Re: Problem with sql reader

Oh, I see. Thanks for the help with that.
Reputation Points: 23
Solved Threads: 6
Posting Pro
Dark_Omen is offline Offline
573 posts
since Apr 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Modifying head tag of parent file.
Next Thread in C# Forum Timeline: Azman Help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC