Single quote handling in a SQL string

后端 未结 3 581
你的背包
你的背包 2020-12-14 18:09

I have an application where the values in the text field are sent to the database.

For example I have a form with one field (text box). When I press Ok button then t

3条回答
  •  庸人自扰
    2020-12-14 18:58

    Hope this will help you ...

    public static string DoQuotes(string sql)
        {
            if (sql == null)
                return "";
            else
                return sql.Replace("'", "''");
        }
    

提交回复
热议问题