且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

删除字符串中的单双引号

更新时间:2023-01-22 21:22:29

如果您使用的是参数(请参阅: ^ ])在您的SQL语句中,引号不会在您的插入,选择等操作中引起问题.

如果用户输入了此数据,则IMO修改数据是个坏主意.应用程序应按原样存储信息.
If you''re using parameters (see: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparameter.aspx[^]) in your SQL statements, the quotes won''t cause problems in your insert, selects etc.

If the user has entered this data, IMO modifying the data is a bad idea. The application should store the information as it is.


此代码可以帮助您
This Code may help you
string Data = TextBox1.Text;
Data = Data.Replace("\"", "");
TextBox1.Text = Data;


想象TextBox1.Text是数据库中的数据


imagine TextBox1.Text is data from database


尝试一下:
Try This one :
Dim S As String = "Your String"
S = S.Remove("'")


希望对您有帮助. :)


I hope it will help you. :)