小编Max*_*yne的帖子

ExecuteNonQuery()上的错误;

我收到以下错误 ExecuteNonQuery()

"String or binary data would be truncated. The statement has been terminated."
Run Code Online (Sandbox Code Playgroud)

问题是要发送的变量大于DB中的变量.我使用以下代码:

      protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        //GridViewRow row = GridView1.SelectedRow;
        GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
        var Username = (Label)row.FindControl("Label3");
        var Password = (Label)row.FindControl("Label4");
        var Email = (Label)row.FindControl("Label5");
       // var ID_Inscricao = ((Label)row.FindControl("Label1")).Text;
        var ID_Inscricao = ((Label)row.FindControl("Label1")).Text;


        SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["FormacaoConnectionString"].ToString());
        SqlCommand sqlComm = new SqlCommand();


        sqlComm = sqlConn.CreateCommand();
        sqlComm.Parameters.Add("@Username", SqlDbType.Text);
        sqlComm.Parameters.Add("@Password", SqlDbType.Text);
        sqlComm.Parameters.Add("@Email", SqlDbType.Text);
        sqlComm.Parameters.Add("@ID_Inscricao", SqlDbType.Int);

        sqlComm.Parameters["@Username"].Value = Convert.ToString(Username);
        sqlComm.Parameters["@Password"].Value = Convert.ToString(Password);
        sqlComm.Parameters["@Email"].Value = …
Run Code Online (Sandbox Code Playgroud)

t-sql asp.net ado.net c#-4.0

2
推荐指数
1
解决办法
1203
查看次数

无法转换值

我试图转换Id字段将其发送到数据库但在DB中类型是bigInt:

var ID_Inscricao = (Label)row.FindControl("Label1");
Run Code Online (Sandbox Code Playgroud)

如何将其转换为与bigInt兼容的类型?我尝试过转换和转换,但都没有奏效.

c# asp.net

0
推荐指数
1
解决办法
148
查看次数

标签 统计

asp.net ×2

ado.net ×1

c# ×1

c#-4.0 ×1

t-sql ×1