locked
Quotation mark issue while updating a datagrid.. RRS feed

  • Question

  • User2140025385 posted

    Hi,

    My problem is this: 

    I have a DataGrid, which i use to update some values. My DATABASE is microsoft access.

    whenever i try to add text that includes quotation mark to the textbox so i can update a certain values, i get a Syntax error saying:

    Syntax error (missing operator) in query expression ''bla bla bla bla..'.....


    this is my sql statement for updating the grid

            string queryStr = "UPDATE [tours] SET [title] = '" + txtBoxTitle.Text + "', [desc] = '" + txtBoxDesc.Text + "', [photo] = '" + txtBoxPhoto.Text + "' WHERE [id] = '" + txtBoxId.Text + "'";

          

     string queryStr = "UPDATE [tours] SET [title] = '" + txtBoxTitle.Text + "', [desc] = '" + txtBoxDesc.Text + "', [photo] = '" + txtBoxPhoto.Text + "' WHERE [id] = '" + txtBoxId.Text + "'";
    


    something is going wrong with the structure of the update statement and the quotation mark i enter in the text. Obviously its confusing the statement. 


    Any help is really appreciated.

    THANKSCool

    Tuesday, July 6, 2010 8:00 PM

Answers

  • User-42918493 posted

    txtBoxTitle.Text.Replace("'","''")

    use like this...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 7, 2010 1:06 AM

All replies