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 = [b]new SqlDataReader[/b]();
existsRdr.[b]Read[/b]();

Anyhelp would be great.
Thanks in advance.

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

SqlConnection myConnection = new SqlConnection(myConnectionString);
SqlCommand myCommand = new SqlCommand(mySelectQuery, myConnection);
 myConnection.Open();
SqlDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
while(myReader.Read()) 
{
    Console.WriteLine(myReader.GetString(0));
}
myReader.Close();
//Implicitly closes the connection because CommandBehavior.CloseConnection was specified.

Oh, I see. Thanks for the help with that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.