这就是我的表格的样子
/****** Object: Table [dbo].[tdn_Winners] Script Date: 08/12/2016 18:55:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tdn_Winners](
[Id] [int] IDENTITY(1,1) NOT NULL,
[MemberId] [int] NULL,
[PrizeNodeId] [int] NULL,
[CampaignNodeId] [int] NULL,
[TransactionId] [int] NULL,
CONSTRAINT [PK_TND_Winners] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
我正在向此表插入一些值,如此
string insertquery = "INSERT INTO [dbo].[tdn_Winners] ([MemberId] ,
[PrizeNodeId] ,[CampaignNodeId] ,[TransactionId]) VALUES(@MemberId,
@PrizeNodeId, @CampaignNodeId, @TransactionId";
int rowsAffected = sqlHelper.ExecuteNonQuery(insertquery,
sqlHelper.CreateParameter(parameterName: "@MemberId", value: 1),
sqlHelper.CreateParameter(parameterName: "@PrizeNodeId", value: 1),
sqlHelper.CreateParameter(parameterName:
"@CampaignNodeId",value: 1), sqlHelper.CreateParameter(parameterName:
"@TransactionId", value: 1));
一切看起来都不错,但这会引发像这样的错误
System.Data.SqlClient.SqlException:'@TransactionId'附近的语法不正确。
有谁可以请指出我在这里做错了什么?
答案 0 :(得分:5)
您缺少结束括号:
<main>'
from /Users/pascalvanderlocht/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in
答案 1 :(得分:0)
@TransactionId
之后的右括号丢失了。
添加并重试。它应该工作。
"INSERT INTO [dbo].[tdn_Winners] (
[MemberId] ,
[PrizeNodeId] ,
[CampaignNodeId] ,
[TransactionId])
VALUES(
@MemberId,
@PrizeNodeId,
@CampaignNodeId,
@TransactionId)";