The error message is very direct-viewing[:)] I guess you're trying to new a SqlDataReader using some constructor, which is not supported. Instead, you can new a SqlDataReader from some funciton which returns a SqlDataReader, for example:
SqlCommand command = new SqlCommand(queryString, connection);
connection.Open();
Thanks for that. But may I know how can I return the result set and bind it to gridview? Below is my code.
public method in Employee class file
public SqlDataReader A(String EmpID)
{
SqlConnection con = new SqlConnection("myconnection");
con.Open();
SqlCommand cmd = new SqlCommand("", con);
cmd.CommandText = "SELECT Emp_Name, Emp_Add from " + EmpID + " WHERE UPPER(Emp_Name) IN (SELECT UPPER(Emp_Name) as Name FROM " + EmpID + " GROUP BY Emp_Name HAVING (COUNT(UPPER(Emp_Name)) > 1)) ORDER BY Emp_Name";
Employee myEmp = new Employee();
grv.DataSource = A ;
grv.DataBind();
May I know normally is the sqldatareader able to read a sqlcommand that have input parameter and return the result set and bind it to gridview? or is there a better way to handle this kind of situation instead of using sqldatareader?
wknet
Member
212 Points
56 Posts
The type 'System.Data.SqlClient.SqlDataReader' has no constructors defined
Sep 23, 2006 12:56 PM|LINK
Dear all,
I'm using sqldatareader to return data that i need and then bind it to the gridview. Anyway, I'm facing the above error message. Please help, thanks.
Levine
mbanavige
All-Star
135168 Points
15505 Posts
ASPInsiders
Moderator
MVP
Re: The type 'System.Data.SqlClient.SqlDataReader' has no constructors defined
Sep 23, 2006 03:31 PM|LINK
Iori_Jay
Star
12940 Points
2450 Posts
Re: The type 'System.Data.SqlClient.SqlDataReader' has no constructors defined
Sep 25, 2006 04:03 AM|LINK
The error message is very direct-viewing[:)] I guess you're trying to new a SqlDataReader using some constructor, which is not supported. Instead, you can new a SqlDataReader from some funciton which returns a SqlDataReader, for example:
SqlCommand command =
new SqlCommand(queryString, connection);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
For more information, please refer to: SqlDataReader Class
http://51up.org/bbs/forumdisplay.php?fid=38
wknet
Member
212 Points
56 Posts
Re: The type 'System.Data.SqlClient.SqlDataReader' has no constructors defined
Sep 26, 2006 05:55 AM|LINK
public method in Employee class file
public SqlDataReader A(String EmpID)
{
SqlConnection con = new SqlConnection("myconnection");
con.Open();
SqlCommand cmd = new SqlCommand("", con);
cmd.CommandText = "SELECT Emp_Name, Emp_Add from " + EmpID + " WHERE UPPER(Emp_Name) IN (SELECT UPPER(Emp_Name) as Name FROM " + EmpID + " GROUP BY Emp_Name HAVING (COUNT(UPPER(Emp_Name)) > 1)) ORDER BY Emp_Name";
SqlDataReader dtr = cmd.ExecuteReader();
return dtr;
}
The code that I have in asp.cs is as below:
Employee myEmp = new Employee();
grv.DataSource = A ;
grv.DataBind();
May I know normally is the sqldatareader able to read a sqlcommand that have input parameter and return the result set and bind it to gridview? or is there a better way to handle this kind of situation instead of using sqldatareader?
Thanks in advance
Levine
wknet
Member
212 Points
56 Posts
Re: The type 'System.Data.SqlClient.SqlDataReader' has no constructors defined
Sep 26, 2006 03:26 PM|LINK
ASP.NETaholi...
Member
15 Points
63 Posts
Re: The type 'System.Data.SqlClient.SqlDataReader' has no constructors defined
Aug 03, 2012 01:57 PM|LINK
I know this is an old thread, but why not leave the answer you arrived at?