Hi @RAVI,
You can use the Regex.Replace method.
If you only have this special character(), use the following code:
string inStr = TextBox4Col.Text.ToString();
string outStr = Regex.Replace(inStr, "\u0002", "");
//.....
cmd1.Parameters.Add(new SqlParameter("@CodeName", outStr));
If there may be other special characters that need to be removed, you can use the following code.
This will replace all non-alphabets and non-numbers.
string inStr = TextBox4Col.Text.ToString();
string outStr = Regex.Replace(inStr, @"[^\w\d]", "");
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.