SqlConnection mycon = new SqlConnection(strcon); mycon.Open(); string strquery = "INSERT INT0 studentDetails values('" + txtName.Text.ToString() + "','" + txtQual.Text.ToString() + "','" + txtAge.Text.ToString() + "','" + txtMobile.Text + "')"; SqlCommand cmd = new SqlCommand(strquery, mycon); cmd.ExecuteNonQuery();
String or binary data would be truncated.
INSERT INTO
INSERT INT0
string strquery = "INSERT INTO studentDetails(col1,col2,col3,col4) values(@col1,@col2,@col3,@col4)"; SqlCommand cmd=new SqlCommand(strquery,con); cmd.Parameters.AddWithValue("col1",txtName.Text); cmd.Parameters.AddWithValue("col2",txtQual.Text); cmd.Parameters.AddWithValue("col3",txtAge.Text); cmd.Parameters.AddWithValue("col4",txtMobile.Text); cmd.ExecuteNonQuery();
"insert into userInfo(name,designation,age,EmailId,MobileNo,address) values ('" + EmpName + "','" + EmpDesig + "'," + Empage + ",'" + EmpEmailId + "','" + EmpMobNo + "','" + EmpAddress + "')"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)