troubleshooting Question

Data not updated in database even though it says "Update successful"

Avatar of Jay
Jay asked on
13 Comments1 Solution154 ViewsLast Modified:
Im using web service, where the data in project B has to be updated in project A,

Heres how i did for the DAL class in project B
 public DataSet UpdateBook(String baddress, String bpostalcode, String bcountry, String saddress, String spostalcode, String scountry, String bcompany, String bcity, String scompany, String scity)
            int result = 0;
            DataSet updateAdd;
            SqlDataAdapter da;
            string queryStr = "UPDATE CompanyAddress"
                + "SET BillingAddress=@billingaddress, BillingPostalCode=@billingpostalcode, BillingCountry=@billingcountry, ShippingAddress=@shippingaddress, ShippingPostalCode=@shippingpostalcode, ShippingCountry=@scountry, BillingCompany=@billingcompany, BillingCity=@billingcity, ShippingCompany=@shippingcompany, ShippingCity=@shippingcity"
                + "WHERE CompAddressId=@compAddressId";
            SqlConnection conn = new SqlConnection(_connStr);
            updateAdd = new DataSet();
            SqlCommand cmd = new SqlCommand(queryStr, conn);
                da = new SqlDataAdapter(queryStr.ToString(), conn);
                cmd.Parameters.AddWithValue("@billingaddress", baddress);
                cmd.Parameters.AddWithValue("@billingpostalcode", bpostalcode);
                cmd.Parameters.AddWithValue("@billingcountry", bcountry);
                cmd.Parameters.AddWithValue("@shippingaddress", saddress);
                cmd.Parameters.AddWithValue("@shippingpostalcode", spostalcode);
                cmd.Parameters.AddWithValue("@scountry", scountry);
                cmd.Parameters.AddWithValue("@billingcompany", bcompany);
                cmd.Parameters.AddWithValue("@billingcity", bcity);
                cmd.Parameters.AddWithValue("@shippingcompany", scompany);
                cmd.Parameters.AddWithValue("@shippingcity", scity);
                result = cmd.ExecuteNonQuery();
            catch (Exception ex)
                errMsg = ex.Message;
            return updateAdd;
And the code behind for project A
 protected void btnUpdateAddress_Click(object sender, EventArgs e)
            BllCompAddressBook updateAdd = new BllCompAddressBook();
            int result = 0;
            if (result == 0)
                DataSet ds = updateAdd.UpdateBookList(tb_bAddress.Text, tb_bPostalCode.Text, tb_bCountry.Text, tb_sAddress.Text, tb_sPostalCode.Text, tb_sCountry.Text, tb_bCompany.Text, tb_bCity.Text, tb_sCompany.Text, tb_sCity.Text);
                Response.Write("<script>alert('Update successful');</script>");
                Response.Write("<script>alert('Update NOT successful.');</script>");
Any idea why??
Join our community to see this answer!
Unlock 1 Answer and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros