帮忙看看这段sql问题出在哪?
sqlString ="DECLARE @CN NVARCHAR(100)"
+" IF EXISTS (select serialnumber from TravelRoutingWorkStationMaterial where DateCodeSN = '" + serail + "' )"
+ " BEGIN "
+ " select @CN = serialnumber from TravelRoutingWorkStationMaterial where DateCodeSN ='" + serail + "'"
+ " set '" + serail + "'=@CN"
+ " END";
DataSet dataset = QueryDataSet(sqlString);
return serail;
------解决方案--------------------这个看着好麻烦啊,建议到sqlserver里去进行代码验证,可以找出哪里错误。
------解决方案--------------------建议你把服务器代码扒下去。。这样太乱了。。没有几个人会愿意看 。。
------解决方案--------------------加断点调试出来sqlString 看看
------解决方案-------------------- + " select @CN = serialnumber from TravelRoutingWorkStationMaterial where DateCodeSN ='" + serail + "'"
+ " set '" + serail + "'=@CN"
serail又是变量名又是字段值?仔细检查一下
------解决方案--------------------单独使用sql语句不可以使用变量