I have an ASP.NET application with C# behind. The application gets data from WebServices and then it should execute the below update.
我有一个ASP。后面有c#的NET应用程序。应用程序从WebServices获取数据,然后执行下面的更新。
sqlQueryString2 = "
UPDATE CI
SET
platform =@platform ,
wstart = @wstart,
wend = @wend,
model = @model,
productDescription = @productDescription,
scanflag = @scanflag
WHERE serial = @serial ";
I realized that my application seems to be looping when certain values are returned from the Web service. The UPDATE is sent, doesn't commit, and then it is picked up again on the next loop as needing to be updated.
我意识到,当从Web服务返回某些值时,我的应用程序似乎正在循环。更新被发送,没有提交,然后在需要更新的下一个循环中再次接收更新。
I did a trace in SQL(Server 2005) and this is what is hitting the server:
我在SQL(服务器2005)中做了一个跟踪,这就是攻击服务器的原因:
exec sp_executesql N'
UPDATE CI
SET
platform =@platform ,
wstart = @wstart,
wend = @wend,
model = @model,
productDescription = @productDescription,
scanflag = @scanflag
WHERE
serial = @serial ',N'
@serial nvarchar(11),
@platform nvarchar(23),
@wstart varchar(10),
@wend nvarchar(10),
@model nvarchar(24),
@productDescription nvarchar(35),
@scanflag nvarchar(1)',
@serial=N'H01170RAHS6',
@platform=N'Client Computer - Apple',
@wstart=N'05/09/2011',
@wend=N'05/09/2012',
@model=N'iMac (20-inch, Mid 2009)',
@productDescription=N'IMAC 20"/2.26/2X1GB/160GB/SD/MSE/KB',
@scanflag=N'Y'
I suspect that the single doublequote in the productDescription might be throwing it, but I have had a bugger of a time trying to strip it out or replace it with (in.). I think part of my issue on that front is the value stored when it is populated by the WebServices server is escaped as I can see it as "IMAC 20\"/2.26/2X1GB/160GB/SD/MSE/KB" in the watch list. I have tried replacing the escaped and non escaped quote with String.Replace as well as a RegEx statement. TBH I'm not even sure I'm on the right track with the quote. I'm only looking at it because not all returns contain one and they don't all loop.
我怀疑productDescription中的单双引号可能会抛出它,但我有一个忙得不可开交的人试图去掉它,或者用(in.)替换它。我认为我的问题的一部分是在WebServices服务器填充时存储的值,我可以把它看作是“IMAC 20\”/2.26/2X1GB/160GB/SD/MSE/KB“在观察列表中。我已经尝试用字符串替换了转义和非转义引号。替换和RegEx语句。TBH我甚至不确定我的报价是否正确。我只看它,因为不是所有的返回都包含一个,它们不都是循环的。
1 个解决方案
#1
1
The double quotes should not be a problem: inside of a string, they are just another character. (They have meaning outside of string constants but that is not what's going on here.)
双引号应该不是问题:在字符串中,它们只是另一个字符。(它们在字符串常量之外有意义,但这里不是这样)
I strongly suspect your problem is not a SQL syntax error. If it were, you'd see it show up in multiple places.
我强烈怀疑您的问题不是SQL语法错误。如果是的话,你会看到它出现在很多地方。
For example, you would see them in SQL Profiler (if you included Errors and Exceptions in your trace). You could also run that exact SQL query you just pasted into SSMS and see that it does/does not work. More to the point, you would be getting a SQL exception on the C# side if the query returns an error. If none of those things are happening, then your query would appear to be working.
例如,您将在SQL Profiler中看到它们(如果在跟踪中包含错误和异常)。您还可以运行刚才粘贴到SSMS中的SQL查询,看看它是否工作。更重要的是,如果查询返回一个错误,您将在c#方面得到一个SQL异常。如果这些事情都没有发生,那么您的查询将显示为正在工作。
More likely, the query is running, but not doing anything, so you are picking up the same records over and over as needing updating. Again, running in SSMS will give you the "1 row(s) updated" message that should help you track this problem down.
更有可能的是,查询正在运行,但没有做任何事情,因此您将在需要更新时反复获取相同的记录。同样,在SSMS中运行将给您“1行更新”消息,这将帮助您跟踪这个问题。
#1
1
The double quotes should not be a problem: inside of a string, they are just another character. (They have meaning outside of string constants but that is not what's going on here.)
双引号应该不是问题:在字符串中,它们只是另一个字符。(它们在字符串常量之外有意义,但这里不是这样)
I strongly suspect your problem is not a SQL syntax error. If it were, you'd see it show up in multiple places.
我强烈怀疑您的问题不是SQL语法错误。如果是的话,你会看到它出现在很多地方。
For example, you would see them in SQL Profiler (if you included Errors and Exceptions in your trace). You could also run that exact SQL query you just pasted into SSMS and see that it does/does not work. More to the point, you would be getting a SQL exception on the C# side if the query returns an error. If none of those things are happening, then your query would appear to be working.
例如,您将在SQL Profiler中看到它们(如果在跟踪中包含错误和异常)。您还可以运行刚才粘贴到SSMS中的SQL查询,看看它是否工作。更重要的是,如果查询返回一个错误,您将在c#方面得到一个SQL异常。如果这些事情都没有发生,那么您的查询将显示为正在工作。
More likely, the query is running, but not doing anything, so you are picking up the same records over and over as needing updating. Again, running in SSMS will give you the "1 row(s) updated" message that should help you track this problem down.
更有可能的是,查询正在运行,但没有做任何事情,因此您将在需要更新时反复获取相同的记录。同样,在SSMS中运行将给您“1行更新”消息,这将帮助您跟踪这个问题。