2011-11-10 44 views
0

我使用下面的SQL語法此語法

command . CommandText="INSERT INTO Group(GroupName, Groupcomment, GroupIconPath) values (@name, @comment ,@path)"; 

然後VS是給我的語法無效近的一組

我查了幾次錯誤得到下面的錯誤,我不發現任何錯誤HMM

回答

0

組是SQL Server中的reserved keyword。可能必須重命名你的表格。

+0

如上所述,您可以通過在表名稱周圍使用括號來轉義保留關鍵字。 – Sam

0

嘗試三..

command . CommandText="INSERT INTO `Group`(GroupName, Groupcomment, GroupIconPath) values (@name, @comment ,@path)"; 
0

group是SQL關鍵字。

把[]周圍像這樣[group]

1

集團是一個保留關鍵字,你可以在方括號把它包起來,使這項工作:

command.CommandText="INSERT INTO [Group](GroupName, Groupcomment, GroupIconPath) values .." 
2

周圍的表名使用括號。這告訴SQL Server,您不是指保留關鍵字。

command.CommandText="INSERT INTO [Group](GroupName, Groupcomment, GroupIconPath) values (@name, @comment ,@path)";