Failed to convert parameter C# / SQL Server

前端 未结 2 1757
我寻月下人不归
我寻月下人不归 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:01

    why you don't use

    comm.Parameters.AddWithValue("@cod", T4.Text);
    
    comm.Parameters.AddWithValue("@facultate", C1.Text);
    comm.Parameters.AddWithValue("@domeniul", T1.Text);
        ... 
    

    comm.Parameters.AddWithValue("@d_inscriere", DTP1.Value);

        ...
        etc
    
    0 讨论(0)
  • 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) });
    
    0 讨论(0)
提交回复
热议问题