Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SqlDataAdapter Update vs Sql Insert?

Posted on 2006-10-27
3
Medium Priority
?
345 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 750 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

704 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