Solved

SqlDataAdapter Update vs Sql Insert?

Posted on 2006-10-27
3
335 Views
Last Modified: 2012-05-05
I've elected to use the following C# "da.Update" code to add the contents of a shopping cart to an MS-SQL datatable named "Sales".

I'm asking in concern for the integrity of the established (preexisting) data within the SQL datatable. That is other clients sales data.

Q. Is the dataset (ds) filled with the SQL datatable data, then combinded with the session dataset (myds), then reloaded into the SQL datatable effectively overwriting the preexisting SQL datatable data...

Q. If a C# "da.Update" glitched during a shopping cart save, is there a possibility that preexisting data could become lost or corrupt?

Q. Is an SQL Insert a safer choice?


[Current Update Code]

            string sql = " Select * From tbl_Sales ";

            SqlConnection cn = new SqlConnection(ConfigurationManager.AppSettings["AspSql"]);
            SqlDataAdapter da = new SqlDataAdapter(sql, cn);
            cn.Open();

            DataSet ds = (DataSet)Session["myds"];

            SqlCommandBuilder cb = new SqlCommandBuilder(da);

            da.Update(ds, "Sales");
            ds.AcceptChanges();
            cn.Close();

0
Comment
Question by:kvnsdr
3 Comments
 
LVL 12

Accepted Solution

by:
deanvanrooyen earned 250 total points
ID: 17824795
either way you want error handling aroun this and at least with an insert using a transaction is easier in sql.
0
 
LVL 1

Author Comment

by:kvnsdr
ID: 18023225
Sorry, I've been on vacation...
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now