insert into dscl_sql_log (user_name, sql_time, sql) values ('ADMIN', '2/17/2014 7:05:45 PM', 'select * from cn_fieldsurvey_trn where unit_code = ''03'' and rownum < 10')
If you are getting value from textbox then it is highly recommended to use parameterized query to prevent SQL Injection Attacks and avoid explicitly escaping single characters in value being passed.
string query= @"insert into dscl_sql_log (user_name, sql_time, sql) values " +
" (" +
@"'ADMIN', '2/17/2014 7:05:45 PM',@sql "+
")";
using (var cmd = new SqlCommand(query, conn))
{
cmd.Parameters.AddWithValue("@sql", txtbox.Text);
cmd.ExecuteNonQuery();
}
= ''03''