473,795 Members | 3,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to persists a DataSet in a Access Table

Hi,
I would like to persist a Dataset Table
in an Access Table

I have a Access Database and I saved
the data in a XML file:

string strSQL = "SELECT * FROM "+TableName ;
OleDbDataAdapte r myDataAdapter = new OleDbDataAdapte r(strSQL, myConnection);
DataSet myDataSet = new DataSet();
myDataAdapter.F ill(myDataSet, TableName);
myConnection.Cl ose();
myDataSet.Write Xml(@"C:\Inetpu b\wwwroot\xxx\W rite\"+TableNam e+".xml");
Then I delete all rows from the Access table and I read the Xml:

DataSet myDataSet = new DataSet();
myDataSet.ReadX ml(@"C:\Inetpub \wwwroot\xxx\Wr ite\"+TableName +".xml");

but now I would like to save back the data (in myDataSet) into the table.

By now I do this "row by row" but I don't like this
Is there some better solution?

Thanks

M.A.
Nov 19 '05 #1
3 1492
Hello Maury,
Check wheather insert , delete and update commands are generated
automatacally by DataAdapter or not. If not then create. and update the
dataset after loading xml file.
For detail please refer DataAdapter's documentation.

Regards,
bhawin13

Nov 19 '05 #2
bh******@indiat imes.com ha scritto:
Check wheather insert , delete and update commands are generated
automatacally by DataAdapter or not. If not then create. and update the
dataset after loading xml file.


Ok, I did it, I added

OleDbCommandBui lder myCb = new OleDbCommandBui lder(myDataAdap ter);

and a so this line now works fine!

myDataAdapter.U pdate(xmlDataSe t.Tables[TableName]);

But I would like to create a new table from
xml schema? It's possible?

Thanks

M.A.
Nov 19 '05 #3
Hello Maury,
It means first you want to create datatable and based on your dataset
you want to create table in database.
Am I right?
If yes, I don't think so it is possible. but you can check it with
database that such table in database yes or no. If yes then just insert
new records to table if no then create table then do operation.

For that i suggest write code to create table in database in event that
will be called before the acutal data is saved to database. Check out
events of dataset, datatable and dataAdapter.

Regards,
bhawin13

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
378
by: Simon Harvey | last post by:
Hi everyone, I was wondering if it is possible, to use SQL to return more than one table at a time into a dataset. I only know the basics of SQL and so I'm not sure if I'm just asking a stupid question. But, I'm not proud! :-) I'm using Ado.net and I'm wanting to load a DataSet object with several independent tables. (For those who arent ADO.net programmers, a DataSet can hold multiple tables and the relationships and contraints...
0
1794
by: Neo | last post by:
I was wondering what is the "right" way to deal with datasets is. Particularly sharing DataSets between forms. Here is my situation. I have a simple Customer Database, that holds some information about Customers including thier address. Lets call this Table "Customers". The Customers Table references another Table for Address information, for instance I have a table of "Zipcodes", Now I want an app with two forms, one form to browse my...
1
6667
by: Jeroen Pot | last post by:
Hi, I have a dataset "Mydataset" which contains of a few fields. (lets say dept_id and dept_name) A user can select several of these, and i want to export this to an access database. I have a database with one table (dept) and identical colums as the dataset. But i can't figure out how to get the dataset into the database.
0
5828
by: M. David Johnson | last post by:
I cannot get my OleDbDataAdapter to update my database table from my local dataset table. The Knowledge Base doesn't seem to help - see item 10 below. I have a Microsoft Access 2000 database which indexes computer magazine articles for personal reference. I am developing a Visual Basic.NET program whose sole purpose is to enter new records into the database. No updates to existing entries, no deletions, and no display
22
4236
by: EMW | last post by:
Hi, I managed to create a SQL server database and a table in it. The table is empty and that brings me to my next chalenge: How can I get the info in the table in the dataset to go in an empty SQL table? Is there a short way like the FILL method to get data into the dataset or do I have to read each datarow in the table and write it one at the time to the
13
1836
by: Lars Netzel | last post by:
hi! myDataSet that is fillled from an Access 2000 db and includes ONE table From that Table in myDataSet I create myDataView and use a Rowfilter to get a few rows that i work with (i need a DataView cause I do a lot of filtering) The problem is the primary key field (a unique counter), let's call it "TBL_ID".
14
2133
by: Lars Netzel | last post by:
A little background: I use three Datagrids that are in a child parent relation. I Use Negative Autoincrement on the the DataTables and that's workning nice. My problem is when I Update these grid and write to the database and I set the new Primary Keys and related Fields to the new asigned atuonumbers in the Access.
2
3702
by: Carl Summers | last post by:
I have a table in an Access database that has no sort applied in Access. When I fill a dataset with data from that table (the entire one dimensional table) my dataset is sorted differently than the database. This would not be a problem, and really isn't a problem except that it means I have to search the dataset each time I want to find a particular record instead of just storing a variable. Which brings me to a different question....
2
2787
by: JT | last post by:
I have an SQL database with one table in it. I want to load the table into a DataSet, add new records to the DataSet, then commit the changes back to the database. Using C#.NET, the following loads the DataSet and fills it: string SelectString = "SELECT * FROM dbo.Trade"; SqlCommand RecordsSelection = new SqlCommand(SelectString, ThisConnection);
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10214
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10164
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9042
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7540
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.