Den*_*ler 1 c# sql sql-server asp.net sql-server-2014
我正在尝试将数据插入我的SQL Server 2014数据库,但是我收到了一个错误
')'附近的语法不正确.
我的表格与我输入的数据类型相匹配,例如,我将其int放入int.
这是我的代码:
string ip = Request.UserHostAddress;
string name = "Jesus said: Love your Enemies (V.S.)";
int blueq = Convert.ToInt32(TextBox1.Text);
int redq = Convert.ToInt32(TextBox2.Text);
int whiteq = Convert.ToInt32(TextBox3.Text);
int blackq = Convert.ToInt32(TextBox4.Text);
int whiteqr = Convert.ToInt32(TextBox9.Text);
int redqr = Convert.ToInt32(TextBox10.Text);
int sn = 600;
int price = total_jslye;
string size;
if (RadioButton1.Checked == false)
{
size = "11x35";
}
else
size = "18x50";
try
{
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["SQLCS"].ConnectionString;
var cmd = "INSERT INTO cartsigns (@SignNumber, @redquantity, @bluequantity, @whitequantity, @blackquantity, @whitereflectivequantity, @redreflectivequantity, @size, @SignName, @ipaddress, @price)";
using (SqlConnection com = new SqlConnection(conn))
{
using (SqlCommand cmds = new SqlCommand(cmd, com))
{
cmds.Parameters.AddWithValue("@SignNumber", sn);
cmds.Parameters.AddWithValue("@redquantity", redq);
cmds.Parameters.AddWithValue("@bluequantity", blueq);
cmds.Parameters.AddWithValue("@whitequantity", whiteq);
cmds.Parameters.AddWithValue("@blackquantity", blackq);
cmds.Parameters.AddWithValue("@whitereflectivequantity", whiteqr);
cmds.Parameters.AddWithValue("@redreflectivequantity", redqr);
cmds.Parameters.AddWithValue("@size", size);
cmds.Parameters.AddWithValue("@SignName", name);
cmds.Parameters.AddWithValue("@ipaddress", ip);
cmds.Parameters.AddWithValue("@price", price);
com.Open();
cmds.ExecuteNonQuery();
}
}
}
Run Code Online (Sandbox Code Playgroud)
所以请帮助,谢谢