Solved

SqlDataAdapter Update vs Sql Insert?

Posted on 2006-10-27
3
344 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
[X]
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
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

617 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