Click here to Skip to main content
15,911,896 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
My code:

SqlDataAdapter da = new SqlDataAdapter((string)ViewState["Sql_Query"],con);
SqlCommandBuilder builder = new SqlCommandBuilder(da);


Error Description:

Error 1 'ProgressiveSchool.SqlCommandBuilder' does not contain a constructor that takes 1 arguments



Looking for Help..
Posted
Comments
Sergey Alexandrovich Kryukov 30-Apr-15 18:26pm    
Show the declaration of ProgressiveSchool.SqlCommandBuilder...
What's unclear with this error message? supply correct set of arguments. This is you who have been told by a compiler what you can use, not us, so this question makes no sense.
—SA
[no name] 30-Apr-15 18:48pm    
When i passed da - SqlDataAdapter object as an arguement on SqlCommandbuilder Constructor, i got squiggly line under new SqlCommandBuilder(da) with that error message. SHouldnt SqlCommad builder should take DataAdapter as an arguement?? even i checked that on MSDN it supposed to .
Sergey Alexandrovich Kryukov 30-Apr-15 19:21pm    
It's better to show what I asked, instead...
—SA
[no name] 30-Apr-15 19:26pm    
public partial class SqlCommandBuilder : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{


}

protected void btnLoad_Click(object sender, EventArgs e)
{
string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
string sqlQuery = "Select * from tblStudent where ID = " + txtID.Text;
SqlDataAdapter da = new SqlDataAdapter(sqlQuery, con);
DataSet ds = new DataSet();
da.Fill(ds, "tblStudent");

ViewState["Sql_Query"] = sqlQuery;
ViewState["DataSet"] = ds;
if (ds.Tables["tblStudent"].Rows.Count > 0)
{
DataRow drw = ds.Tables["tblStudent"].Rows[0];
txtName.Text = drw["Name"].ToString();
ddlGender.SelectedValue = drw["Gender"].ToString();
txtTotalMark.Text = drw["TotalMarks"].ToString();
}
else
{
lblMessage.Text = "No student record with ID : " + txtID.Text;
}
}
}

protected void btnUpload_Click(object sender, EventArgs e)
{
string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
SqlDataAdapter da = new SqlDataAdapter((string)ViewState["Sql_Query"],con);
SqlCommandBuilder builder = new SqlCommandBuilder(da);


}
[no name] 30-Apr-15 19:27pm    
if that's helpful to u

1 solution

Your SqlCommandBuilder code shows that there is no constructor defined. It means that there is only the default, parameterless constructor. Therefore, you cannot call the non-existing constructor new SqlCommandBuilder(da).

That's all. As simple as that.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900