标题:请各位大神帮帮忙,将截断字符串或二进制数据。 语句已终止。问题
只看楼主
totototo
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2014-11-8
 问题点数:0 回复次数:4 
请各位大神帮帮忙,将截断字符串或二进制数据。 语句已终止。问题
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);
    }
我已经对数据库进行了修改,加大了数据限制。但是仍然有这个错误。
搜索更多相关主题的帖子: private 二进制 字符串 
2014-11-08 12:22
totototo
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2014-11-8
得分:0 
2014-11-08 12:23
zgshj
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2014-11-10
得分:0 
字段长度不够吧
2014-11-10 10:11
yms123
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
得分:0 
字段长度不够的问题,加大字段长度
2014-11-11 10:40



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-438286-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.091966 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved