Posted in
Asp.net,
C#,
Database Query String
There were always problem with Adding Values to query string...
Consistent way:
const string query = "insert into TABLENAME (Id, Name) Values(?,?)";object[] ParameterValues = {IntId,StrName};SqlConnection connection = new SqlConnection(connection_string);SqlCommand command = new SqlCommand(query, connection);foreach (object parameterValue in ParameterValues){command.Parameters.AddWithValue("", parameterValue);}connection.Open();command.ExecuteNonQuery();
So with this way we can add all the special characters like without using \(Back slash) to a sql Database.
Hope its usefull..