Sunday 23 September 2012

Error Occured: Syntax Error(missing operator) in query Expression

Error Occured: Syntax Error(missing operator) in query Expression 

 Below Is The Code In Update Statement That Is Causing Error..

 OleDbCommand cmd = new OleDbCommand("UPDATE Vendor_Details SET Date1='" + CurrentDatePicker1.Text + "'"+
                "VendorName='" + txtVendorName.Text + "',AccountNumber='" + txtAcountNo.Text + "',Address='" + txtAddress.Text + "'"+
   "PhoneNumber='" + txtPhoneNo.Text + "',EMail='" + txtEMail.Text + "',Fax='" + txtFax.Text + "' WHERE VendorName='" + txtVendorName.Text + "'", con);

In The Above Statement While Concatenating The Statement With "+"  For Convenience To See The Code In Single Screen.I had Missed Commas(,) So The Error Is Occured.


After Modifiying The Update Statement Will Be Like This:


OleDbCommand cmd = new OleDbCommand("UPDATE Vendor_Details SET Date1='" + CurrentDatePicker1.Text + "',"+
                "VendorName='" + txtVendorName.Text + "',AccountNumber='" + txtAcountNo.Text + "',Address='" + txtAddress.Text + "',"+
   "PhoneNumber='" + txtPhoneNo.Text + "',EMail='" + txtEMail.Text + "',Fax='" + txtFax.Text + "'+
 WHERE VendorName='" + txtVendorName.Text + "'", con);



After Modifing Update Statement...I Got The Result Successfully


No comments:

Post a Comment

Note: only a member of this blog may post a comment.