Creating safe SQL statements as strings

后端 未结 5 2003
终归单人心
终归单人心 2020-12-03 17:51

I\'m using C# and .NET 3.5. I need to generate and store some T-SQL insert statements which will be executed later on a remote server.

For example, I have an array o

5条回答
  •  生来不讨喜
    2020-12-03 18:34

    Fix your replace quotes function this way:

    void string replaceQuotes(string value) {
         string tmp = value;
         tmp = tmp.Replace("'", "''");
         return tmp;
    }
    

    Cheers!

提交回复
热议问题