R
REB
I have a button that executes this sql query:
sqlcmdInsertPhysicalNote.CommandText = "INSERT INTO DriverPhysicalNotes
(DriverInformationID, PhysicalNoteDate, PhysicalNote) VALUES ('" +
ddlDriverName.SelectedValue + "','" + DateTime.Now.ToShortDateString() +
"','" + txtNotes.Text + "')";
I am having a problem when a user enters an apostrophe ' into the textbox it
cause the save to error out. THis is the error
System.Data.SqlClient.SqlException: Unclosed quotation mark before the
character string 'Test in a quote')'. Line 1: Incorrect syntax near 'Test in
a quote')'. at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at
DOT.Driver.btnAddPhysicalNote_Click(Object sender, EventArgs e)
How can I keep this from happening? Quotes in the notes section should be
allowed.
Thanks,
REB
sqlcmdInsertPhysicalNote.CommandText = "INSERT INTO DriverPhysicalNotes
(DriverInformationID, PhysicalNoteDate, PhysicalNote) VALUES ('" +
ddlDriverName.SelectedValue + "','" + DateTime.Now.ToShortDateString() +
"','" + txtNotes.Text + "')";
I am having a problem when a user enters an apostrophe ' into the textbox it
cause the save to error out. THis is the error
System.Data.SqlClient.SqlException: Unclosed quotation mark before the
character string 'Test in a quote')'. Line 1: Incorrect syntax near 'Test in
a quote')'. at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at
DOT.Driver.btnAddPhysicalNote_Click(Object sender, EventArgs e)
How can I keep this from happening? Quotes in the notes section should be
allowed.
Thanks,
REB