我想传递一个包含字符的脚本”通过传递“从C#到SQL Server
thisCommand.ExecuteNonQuery();
问题从C#到SQL服务器的字符串被表示为“而不是” \:字符串
thisCommand.CommandText = SQLscript; (string SQLScript)
我怎么能转换所有的“字符为\”里面,这样在SQL我只得到“
感谢咨询 看完剧本:
StreamReader s = new StreamReader("export_script.sql");
this.SQLscript = s.ReadToEnd();
执行脚本:
thisCommand.CommandText = SQLscript;
thisCommand.ExecuteNonQuery();
里面的脚本我有类似:
set @cmd = 'bcp "'+ @cmd_select + '" queryout "' + @partname + '" -c -S ' + @@SERVERNAME
你可以看到,我用“为BCP命令
请出示你如何现在这样做(即什么是你的'SQLscript'里面的文字) – dasblinkenlight 2012-02-08 15:16:51
[C#在字符串中有一个\无\ \]的可能重复(http://stackoverflow.com/questions/9120129/c-sharp-have-不要在字符串中传递数据 – 2012-02-08 15:19:21
不要在sql字符串中传递数据总是使用'SqlCommand'和'SqlParameter'。*(破记录...)* – 2012-02-08 15:19:32