Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

SqlDataAdapter Update vs Sql Insert?

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …

856 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