本文介绍了String.Replace不工作???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这太奇怪了,我犹豫发布它,但我需要让它工作。


我的代码看起来像这样......


Private Const cmdTestResourcesSel =" SELECT * FROM TResources" &安培; _

"在哪里场景=

@场景"

Dim cmdstr as String


cmdstr = cmdTestResourcesSel

如果历史然后

cmdstr.Replace(" TResources"," TResourcesHistory")

结束如果

Dim cmdS As SqlCommand = New SqlCommand( cmdstr,cnTest)


历史是真的。走出如果语句,cmdstr不变。

SQLCommand的CommandText包含TResources和TResources。不是TResourcesHistory

这个相同的代码模板在大约十二个其他

位置的同一个程序中工作。没有例外。我可以在调试应用程序时在

命令窗口中对cmdstr进行替换,它运行正常。


这有什么用?


感谢您的帮助。


BBM

This is so bizarre I hesitate to post it, but I need to get this working.

My code looks like this...

Private Const cmdTestResourcesSel = "SELECT * FROM TResources" & _
" WHERE Scenario =
@Scenario"
Dim cmdstr as String

cmdstr = cmdTestResourcesSel
If history Then
cmdstr.Replace("TResources", "TResourcesHistory")
End If
Dim cmdS As SqlCommand = New SqlCommand(cmdstr, cnTest)

History is true. Coming out of the "if" statement, cmdstr is unchanged.
CommandText of the SQLCommand contains "TResources" not "TResourcesHistory"
This same code template works in the same program in about a dozen other
places. No exceptions thrown. I can do the replace on cmdstr in the
command window while debugging the app and it works fine.

What''s up with this???

Thanks for your help.

BBM

推荐答案






这篇关于String.Replace不工作???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-14 02:42