| | |
Problem with sql reader
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2004
Posts: 573
Reputation:
Solved Threads: 5
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:
Anyhelp would be great.
Thanks in advance.
Here is the code from the program:
SqlDataReader existsRdr = new SqlDataReader(); existsRdr.Read();
Anyhelp would be great.
Thanks in advance.
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
You return a SqlDataReader as the result of the .ExecuteReader() method of the Command object:
C# Syntax (Toggle Plain Text)
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.
![]() |
Similar Threads
- Problem with php and SQL (PHP)
- Problem Inserting into SQL database on server (ASP.NET)
- SQL Server 2000 Help (MS SQL)
- Problem with URL access to SQL Server 2000 db (RSS, Web Services and SOAP)
- problem with connection to sql server (ASP.NET)
- Prblem with sql sever connection (ASP.NET)
Other Threads in the C# Forum
- Previous Thread: Modifying head tag of parent file.
- Next Thread: C#ASP.Net: how to browse the folder list on Server?
| Thread Tools | Search this Thread |
.net access algorithm array barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom cyclethruopenforms data database datagrid datagridview dataset date/time datetime degrees development dll draganddrop drawing encryption enum event excel file finalyearproject form format forms function gdi+ getoutlookcontactusinfcsvfile globalization httpwebrequest image index input install installer java label list listbox mandelbrot math mono mouseclick mysql operator panel path photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox save server silverlight sleep socket sql sql-server statistics stream string table text textbox thread time timer timespan update usercontrol users validate validation visualstudio webbrowser wia windows winforms wpf xml






