C#怎么用@符写SQL代码,不用+=连,因为涉及到GO,用@的话文本框的内容要怎么取出来
stringinsert="INSERTINTO[AviationAccidentDatabase].[dbo].[AirportInformation]";insert...
string insert = "INSERT INTO [AviationAccidentDatabase].[dbo].[AirportInformation]";
insert += "([Airport_PKID]";
insert += ",[AirportName]";
insert += ",[ThreeCode]";
insert += ",[ICAOCode])";
insert += "VALUES ";
insert += "(NEWID(),";
insert += "'" + textBoxDeparture.Text + "',";
insert += "'" + textBoxDepT.Text + "',";
insert += "'" + textBoxDepF.Text + "')";
insert += "GO"; 展开
insert += "([Airport_PKID]";
insert += ",[AirportName]";
insert += ",[ThreeCode]";
insert += ",[ICAOCode])";
insert += "VALUES ";
insert += "(NEWID(),";
insert += "'" + textBoxDeparture.Text + "',";
insert += "'" + textBoxDepT.Text + "',";
insert += "'" + textBoxDepF.Text + "')";
insert += "GO"; 展开
2个回答
展开全部
string insert =String.Format(@"
INSERT INTO [AviationAccidentDatabase].[dbo].[AirportInformation]
([Airport_PKID],[AirportName],[ThreeCode],[ICAOCode])
VALUES(newid(),'{0}','{1}','{2}') Go",textBoxDeparture.Text ,textBoxDepT.Text , textBoxDepF.Text) ;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询