注册 登录
编程论坛 ASP.NET技术论坛

请各位大神帮帮忙,将截断字符串或二进制数据。 语句已终止。问题

totototo 发布于 2014-11-08 12:22, 1668 次点击
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);
    }
我已经对数据库进行了修改,加大了数据限制。但是仍然有这个错误。
4 回复
#2
totototo2014-11-08 12:23
只有本站会员才能查看附件,请 登录
#3
zgshj2014-11-10 10:11
字段长度不够吧
#4
yms1232014-11-11 10:40
字段长度不够的问题,加大字段长度
1