473,386 Members | 1,803 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,386 software developers and data experts.

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;
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(strSQL, myConnection);
DataSet myDataSet = new DataSet();
myDataAdapter.Fill(myDataSet, TableName);
myConnection.Close();
myDataSet.WriteXml(@"C:\Inetpub\wwwroot\xxx\Write\ "+TableName+".xml");
Then I delete all rows from the Access table and I read the Xml:

DataSet myDataSet = new DataSet();
myDataSet.ReadXml(@"C:\Inetpub\wwwroot\xxx\Write\" +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 1481
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******@indiatimes.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

OleDbCommandBuilder myCb = new OleDbCommandBuilder(myDataAdapter);

and a so this line now works fine!

myDataAdapter.Update(xmlDataSet.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
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...
0
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...
1
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...
0
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...
22
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...
13
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...
14
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...
2
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...
2
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.