Solved

SqlDataAdapter Update vs Sql Insert?

Posted on 2006-10-27
3
340 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

776 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