string sqlString = "SELECT * FROM Customers WHERE Name='" + txtName.Text + "'"; |
Here if
txtName.text = "O'Brian";
We will get an error as the Apostrophe will split the sql statement. Simply replace the Apostrophe (’) with twho Apostrophes (”) and pass the sql statement.
sqlString = sqlString .Replace("'","''"); |