我正在向数据库中插入值,但是当要插入的值带有撇号(例如 Jo's)时出现错误。我该如何解决这个问题?这是我的代码
SqlDataReader readerReference = cmd_Reference.ExecuteReader();
int loginIndex = readerReference.GetOrdinal("a column");
int DomCodeLoginIndex = readerReference.GetOrdinal("a column");
int dom_domain = readerReference.GetOrdinal("dom_domaine");
int emp_surname = readerReference.GetOrdinal("a column");
int emp_name = readerReference.GetOrdinal("a column");
int srv_name = readerReference.GetOrdinal("a column");
int emp_model_tel = readerReference.GetOrdinal("a column");
int emp_EntryDate = readerReference.GetOrdinal("a column");
int emp_Telephone = readerReference.GetOrdinal("a column");
int emp_Mobile = readerReference.GetOrdinal("a column");
int emp_Email = readerReference.GetOrdinal("a column");
string insert = "INSERT INTO EMP_tracking(emp_login, emp_dom_code, emp_domain, emp_affectation_date, emp_surname" +
",emp_name, emp_service,emp_telephone_model" +
",emp_entry_date" +
",emp_telephone_number" +
",emp_cellphone_number" +
",emp_email) VALUES ('{0}',{1},'{2}','"+DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") +"','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')";
string toInsert = string.Format(insert, readerReference.GetString(loginIndex),
readerReference.GetInt32(DomCodeLoginIndex ),
readerReference.GetString(dom_domain),
readerReference.GetString(emp_surname ),
readerReference.GetString(emp_name),
readerReference.GetString(srv_name),
readerReference.GetString(emp_model_tel),
readerReference.GetDateTime(emp_EntryDate),
readerReference.GetString(emp_Telephone),
readerReference.GetString(emp_Mobile),
readerReference.GetString(emp_Email)
);
cmd_Insert.CommandText = toInsert;
cmd_Insert.ExecuteNonQuery();
假设相关列是emp_login。解决方案将如何在其上实施?