嘿,我正在尝试运行此查询:
command.UseSqlCommand("INSERT INTO DisplayOrders Values ('" + OrderId.Text + "','" + "(SELECT ProductId FROM Products WHERE ProductName =N'" + listBox1.Text + "')','" + listBox1.Text + "','" + OrderQuantity.Text + "','" + TotalCost.Text + "')");
现在command.UseSqlCommand
只是运行查询,但我不断收到此错误:
'intel' 附近的语法不正确
(英特尔是“产品名称”(我从这里得到:
SELECT ProductId FROM Products WHERE ProductName =N'" + listBox1.Text + "'
编辑:这是命令的值,(在'intel'附近得到'不正确的语法')
INSERT INTO DisplayOrders
Values ('2', '(SELECT ProductId FROM Products WHERE ProductName =N'Intel Quad Core i5 3470 3.2Ghz 6MB Tray')','Intel Quad Core i5 3470 3.2Ghz 6MB Tray','1','900')"