this is my code:
1myconnection =new SqlConnection(kiemtraloi,chuoiketnoi);2mycommand.Parameters.Add(new SqlParameter("@.mancc",SqlDbType.VarChar,10));3mycommand.Parameters["@.mancc"].Value = TextBox1.Text;4myconnection.Open();5myreader = mycommand.ExecuteReader();6if(myreader.HasRows)
And when I click to start button, a error appear:
NO overload for method 'sqlconnection' takes '2' arguments
I don't know what i must do :(, please help me
thx
Is that all you have or do you have more code? Where is the SQL statement? and the command object?|||string chuoiketnoi = System.Configuration.ConfigurationSettings.AppSettings["myconn"];
System.Data.SqlClient.SqlConnection myconnection;
System.Data.SqlClient.SqlCommand mycommand;
System.Data.SqlClient.SqlDataAdapter myadapter;
System.Data.SqlClient.SqlDataReader myreader;
System.Data.DataSet mydataset;
// khai bao chuoi cho maytinh
string selectquery = "Select * from maytinh";
string insertquery="Insert into maytinh(mamay) values(@.mamay)";
string updatequery="Update maytinh set mamay=@.mamoi where mamay=@.mamay";
string deletequery = "Delete from maytinh where(mamay=@.mamay)";
// khai bao chuoi cho nhacungcap
string selectnhacungcap="Select * from nhacungcap";
string insertnhacungcap="Insert into nhacungcap(mancc,tenncc,diachi,dienthoai) values(@.mancc,@.tenncc,@.diachi,@.dienthoai)";
string updatenhacungcap="Update nhacungcap set mancc=@.manccmoi,tenncc=@.tennccmoi,diachi=@.diachimoi,dienthoai=@.dienthoaimoi where mancc=@.mancc";
string deletenhacungcap="Delete from nhacungcap where(mancc=@.mancc)";
string kiemtraloi = "Select * from nhacungcap where mancc=@.mancc";
|||That's because the constructor of SqlConnection class only takes 0 or 1 argument, but you pass 2 arguments to it:
myconnection =new SqlConnection(kiemtraloi,chuoiketnoi);
Why did you pass 2 strings to the constructor?
|||I think he wants:
myconnection=new SqlConnection(chuoiketnoi);
mycommand=new SqlCommand(kiemtraloi,myconnection);
sql
No comments:
Post a Comment