地址文本框中有单引号和双引号.如何插入数据库.我正在使用SQL2005.我的代码如下......
str = "exec sp_cust_reg '" + customer.Cust_Id + "','" + customer.Cust_Name + "','" + customer.Gender + "','" + customer.Acc_no + "','" + customer.Address + "','" + customer.Pin_no + "','" + customer.Phone_no + "','" + customer.Mobile_no + "','" + customer.Email + "','" + customer.Authorise + "'";
Run Code Online (Sandbox Code Playgroud)
地址是jo"hn's house
它的Text Visualizer如下......
exec sp_cust_reg 'C7','George Joseph','Male','0001-212123','jo"hn's house','515151','04862787896','8888888888','johnyqw@gmail.com','N'
Run Code Online (Sandbox Code Playgroud)
我用了
string sql = str.Replace("\'", " ");.
Run Code Online (Sandbox Code Playgroud)
然后我明白了
exec sp_cust_reg C7 , George Joseph , Male , 0001-212123 , jo"hn s house , 515151 , …Run Code Online (Sandbox Code Playgroud)