sql server 2008 - DataAdapter.Update() doesn't work to update -


my sql statments follows insert statement works update , delete statements don't work

purchase_invoiceno primary key column of purchase table value , insert value purchaseproduct table "select ident_current ('purchase') [purchase_invoiceno]"

        string deletecmd_purchaseproduct =             @"delete purchaseproduct " +             "purchaseproduct_no=@purchaseproduct_no , "+             "purchase_invoiceno=@purchase_invoiceno ";          string updatcmd_purchaseproduct =             "update purchaseproduct "         + "  set    "         + "  purchaseproduct_serialno =@purchaseproduct_serialno"         + ", purchase_invoiceno =@purchase_invoiceno"         + ", productno =@productno"         + " purchaseproduct_quantity =@purchaseproduct_quantity "         + ", purchaseproduct_unit =@purchaseproduct_unit"         + ", purchaseproduct_price =@purchaseproduct_price"         + " "         + " purchaseproduct_no=@purchaseproduct_no";            string insertcmd_purchaseproduct = "insert purchaseproduct" +                            "(" +                            " purchaseproduct_serialno"+                            ",purchase_invoiceno" +                            ",productno" +                            ",purchaseproduct_quantity " +                            ",purchaseproduct_price" +                            ",purchaseproduct_unit" +    //6                            ")" +                             "values" +                            "(" +                            " @purchaseproduct_serialno"+                            ",@purchase_invoiceno" +                            ",@productno " +                            ",@purchaseproduct_quantity " +                            ",@purchaseproduct_price" +                            ",@purchaseproduct_unit" +       //6                            ");"; 

your delete command appears incomplete:

string deletecmd_purchaseproduct =             @"delete purchaseproduct " +             "purchaseproduct_no=@purchaseproduct_no , "+             "purchase_invoiceno=@purchase_invoiceno "; 

should be:

string deletecmd_purchaseproduct =             @"delete purchaseproduct where" +             "purchaseproduct_no=@purchaseproduct_no , "+             "purchase_invoiceno=@purchase_invoiceno "; 

i can't see why insert should fail unless you're inserting duplicate primary key value or you're not inserting data non-nullable field not have default.

    string updatcmd_purchaseproduct =       "update purchaseproduct "     + "set    purchaseproduct_serialno = @purchaseproduct_serialno, "     + "purchase_invoiceno = @purchase_invoiceno, "     + "productno = @productno, "     + "purchaseproduct_quantity = @purchaseproduct_quantity, "     + "purchaseproduct_unit = @purchaseproduct_unit, "     + "purchaseproduct_price = @purchaseproduct_price "     + "where purchaseproduct_no = @purchaseproduct_no"; 

there missing comma above.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -