I have the following code which iterates through a CSV file and writes to the SQL table:
foreach (string line in lines.Skip(1))
{
var sqlfmt = "INSERT INTO [" + tab + "] values ({0})";
var insert = string.Format(sqlfmt, line.Replace("\"", "'"));
MessageBox.Show(insert + "");
SqlCommand ty = new SqlCommand(insert, myConnection);
ty.ExecuteNonQuery();
}
The issue I have now is if one of the column has '
in the text my application crashes.
What would be the best way to avoid the issue?