473,385 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

A better way to clone and update a table to MS Access?

Hello,

I have written an app that does a deep clone copy from an MS Access database, migrates and inserts the data to another.

The following is my current implementation:
..........
1. I'm using the strongly typed DataSet classes code-gened by VS2008 when you add an OleDb (MS Access) data source.
2. "DestDataSet" and SrcDataSet share the same schema.
..........
Expand|Select|Wrap|Line Numbers
  1. private void copy(DestDataSet dsDest, SrcDataSet dsSrc)
  2. {
  3.     for (int i = 0; i < dsSource.TableA.Count; i++)
  4.     {
  5.         DestDataSet.TableARow rowDest = dsDest.TableA.NewTableARow();
  6.  
  7.         if (!((SrcDataSet.TableARow)dsSrc.TableA.Rows[i]).IsCol1Null())
  8.            rowDest.Col1 = ((SrcDataSet.TableARow)dsSrc.TableA.Rows[i]).Col1;
  9.  
  10.         // repeat for Col2,..., Coln
  11.  
  12.         dsDest.TableA.Rows.Add(rowDest);
  13.     }
  14.  
  15.     try
  16.     {
  17.         DestDataSetTableAdapters.TableAAdapter adpA = new DestDataSetTableAdapters.TableAAdapter();
  18.  
  19.         adpA.Update(dsDest.TableA);
  20.     }
  21.     catch (Exception e)
  22.     {
  23.         Console.WriteLine(e.Message);
  24.     }
  25. }
  26.  
Is there a better way of populating the row? I've tried using

Expand|Select|Wrap|Line Numbers
  1. foreach (SrcDataSet.TableARow row in dsSrc.TableA.Rows)
  2.     dsDest.TableA.ImportRow(row);
  3.  
  4. dsDest.AcceptChanges();
  5.  
but adpA.Update() after the loop does not seem to insert the data into the Db even though there was no runtime execption.

Thanks!
Aug 20 '10 #1

✓ answered by Aimee Bailey

Why dont you just use a query? in SQL all you need to do is use one, and i believe it can be done in Access also, documentation can be found here:

http://msdn.microsoft.com/en-us/libr...ffice.12).aspx

Best of luck :)

Aimee

1 1773
Aimee Bailey
197 Expert 100+
Why dont you just use a query? in SQL all you need to do is use one, and i believe it can be done in Access also, documentation can be found here:

http://msdn.microsoft.com/en-us/libr...ffice.12).aspx

Best of luck :)

Aimee
Aug 22 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: amwi | last post by:
I have tried to solve this on my own for a long time now, so i really need some help here... I use Oracle 10.1 and SQL *plus 10.1. How do i update table a.fkid from table b.pkid with the...
2
by: Mike Leahy | last post by:
Hello all, This question is related to updating tables - is there any way to calculate or update the values in a column in a table to the values in a field produced by a query result? An...
9
by: Deja User | last post by:
This is probably very simple but I can't figure out a way to update one table from another table. Here is an example: ------ TABLEA ------ first_name last_name
1
by: TG | last post by:
How do you update an Access 2000 database table that records a checkbox value into a record? Thanks TG
2
by: PawelR | last post by:
Hello Group, In my apps I fill DataSet from MSAcces (file db1.mdb) oleDbDataAdapter1.Fill(fromAccessDS,"MyTable") MyTable heve 4 columns, I change in dataGrid...
2
by: Ennio-Sr | last post by:
Hi! I'm thinking about creating a table listing my shares (say 'Shares') and then update its price column from a .txt file (say 'Prices') downloaded from an internet site periodically. Recalling...
2
by: Paul712 | last post by:
Recently, I have a table that I use to update a master table. When I run the same Update query that's been successful in the past, most all of the data in the fields in the update fields has been...
5
by: SQL Learner | last post by:
Hi Alex (Kuznetsov) and All, This is to follow up with my last post, "Link two tables using partial word match". How can I UPDATE table using partial word match? How can I write a SQL statement...
1
by: mrobinsc | last post by:
** This SQL statement returns 4 rows SELECT COUNT(*) G.ACTIVITY_ID G.RESOURCE_TYPE G.RESOURCE_CATEGORY G.RESOURCE_SUB_CAT G.ANALYSIS_TYPE G.PROJECT_ID
1
by: adithi | last post by:
My Table Structure is: Table A Table B Table C colA -PK Col B-PK Col C-PK Col B-FK ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.