How to pass variable into SqlCommand statement and insert into database table

前端 未结 2 1527
南旧
南旧 2020-12-12 03:23

I\'m writing a small program in C# that uses SQL to store values into a database at runtime based on input by the user.

The only problem is I can\'t figure out the c

2条回答
  •  失恋的感觉
    2020-12-12 03:48

    Add a parameter to the command before executing it:

    cmd.Parameters.Add("@num", SqlDbType.Int).Value = num;
    

提交回复
热议问题