Failed to convert parameter C# / SQL Server

前端 未结 2 1758
我寻月下人不归
我寻月下人不归 2021-01-26 02:47

Getting error:

Failed to convert parameter value from string to a Int32

I write that code for my form and at finally when run the co

2条回答
  •  情歌与酒
    2021-01-26 03:16

    You are setting int parameter with strings like in:

    comm.Parameters.Add(new SqlParameter("@cod", SqlDbType.Int) { Value = T4.Text });
    

    You should parse the value in all these lines that are integers with something like:

    comm.Parameters.Add(new SqlParameter("@cod", SqlDbType.Int) { Value = int.Parse(T4.Text) });
    

提交回复
热议问题