请各位大神帮帮忙,将截断字符串或二进制数据。 语句已终止。问题
protected void Button_sure_Click(object sender, EventArgs e){
int id = Int32.Parse(Textid.Text.ToString());
string name = stuName.ToString();
string stunumber = stunum.ToString();
string pass = stupassword.ToString();
string sex = Dropsex.ToString();
string bir = stubrithday.ToString();
int claid = Int32.Parse(Dropcla.SelectedValue.ToString());
InsertNews(id, stunumber, name, pass, sex, bir, claid);
}
private void InsertNews(int id,string snumber, string sname, string password, string sex, string bir , int claid)
{
SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["stusystemConnectionString"].ConnectionString);
string cmdText = "INSERT INTO student(stuid,stunumber, stuname, stupassword, stusex,stubirthday, claid)VALUES(" +
id + ",'" +
snumber + "','" +
sname + "','" +
password + "','" +
sex + "','" +
bir + "'," +
claid + ")";
SqlCommand myCommand = new SqlCommand(cmdText, myConnection);
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
}
catch (SqlException ex)
{
throw new Exception(ex.Message, ex);
}
finally
{
myConnection.Close();
}
ClientScript.RegisterStartupScript(GetType(), "alter", "alter('添加成功!');", true);
}
我已经对数据库进行了修改,加大了数据限制。但是仍然有这个错误。