locked
Incorrect syntax near = RRS feed

  • Question

  • User-534424163 posted
    Some one please help
    SqldataAdapter cmd = new sqldataAdapter ("update complaint_details set Resolution='"+textbox1.text"' where complaint_id = '"+ textbox2.text+"',con);
    Dataset ds= new Dataset();
    Cmd.fill(ds);
    Con.close();

    Please ignore Letter sensitive
    Wednesday, August 10, 2016 8:42 PM

Answers

  • User2103319870 posted

    Incorrect Syntax near =

    SqldataAdapter cmd = new sqldataAdapter ("update complaint_details set Resolution='"+textbox1.text"' where complaint_id = '"+ textbox2.text+"',con);

    Change your code like below

     SqldataAdapter cmd = new sqldataAdapter ("update complaint_details set Resolution='"+ textbox1.text +"' where complaint_id = '"+  textbox2.text +"'",con);
                    Dataset ds= new Dataset();
                    Cmd.fill(ds);
                    Con.close();

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 10, 2016 9:26 PM
  • User475983607 posted

    The string concatenation is incorrect.

    "update complaint_details set Resolution='"+textbox1.text"' where complaint_id = '"+ textbox2.text+"'

    Should be this.

    "update complaint_details set Resolution = '" + textbox1.Text + "' where complaint_id = '" + textbox2.Text + "'"

    Also this approach is susceptible to SQL injection attached.  You should always use parameterized queries.

    https://msdn.microsoft.com/en-us/library/bb738521(v=vs.100).aspx

    https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.parameters(v=vs.110).aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 10, 2016 9:34 PM

All replies

  • User2103319870 posted

    Incorrect Syntax near =

    SqldataAdapter cmd = new sqldataAdapter ("update complaint_details set Resolution='"+textbox1.text"' where complaint_id = '"+ textbox2.text+"',con);

    Change your code like below

     SqldataAdapter cmd = new sqldataAdapter ("update complaint_details set Resolution='"+ textbox1.text +"' where complaint_id = '"+  textbox2.text +"'",con);
                    Dataset ds= new Dataset();
                    Cmd.fill(ds);
                    Con.close();

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 10, 2016 9:26 PM
  • User475983607 posted

    The string concatenation is incorrect.

    "update complaint_details set Resolution='"+textbox1.text"' where complaint_id = '"+ textbox2.text+"'

    Should be this.

    "update complaint_details set Resolution = '" + textbox1.Text + "' where complaint_id = '" + textbox2.Text + "'"

    Also this approach is susceptible to SQL injection attached.  You should always use parameterized queries.

    https://msdn.microsoft.com/en-us/library/bb738521(v=vs.100).aspx

    https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.parameters(v=vs.110).aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 10, 2016 9:34 PM