Re: Backup and restore a DataSet connected to MSDE2K with XML
From: Ray Stevens (RayStevens_at_discussions.microsoft.com)
Date: 08/04/04
- Next message: Patrick Bates: "Re: Persisted Recordsets"
- Previous message: Alan: "Re: SQL Server connectivity"
- In reply to: Val Mazur: "Re: Backup and restore a DataSet connected to MSDE2K with XML"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 4 Aug 2004 10:03:05 -0700
Hi Val,
Here is the code for the "Back Up" and "Restore" buttons:
private void Backupmi_Click(object sender, System.EventArgs e) {
SaveFileDialog BackupDialog = new SaveFileDialog();
BackupDialog.Filter = "Back Up Files (*.xml)|*.xml";
BackupDialog.FilterIndex = 1;
BackupDialog.InitialDirectory = "C:\\Documents and Settings\\Ray\\My Documents\\Visual Studio Projects\\Pedigrees\\CatPed\\Backup";
BackupDialog.RestoreDirectory = true;
if (BackupDialog.ShowDialog() == DialogResult.OK) {
// Save the DataSet
dsCats1.WriteXml(BackupDialog.FileName, XmlWriteMode.WriteSchema);
}
}
private void Restoremi_Click(object sender, System.EventArgs e) {
OpenFileDialog RestoreDialog = new OpenFileDialog();
RestoreDialog.Filter = "Back Up Files (*.xml)|*.xml";
RestoreDialog.FilterIndex = 1;
RestoreDialog.InitialDirectory = "C:\\Documents and Settings\\Ray\\My Documents\\Visual Studio Projects\\Pedigrees\\CatPed\\Backup";
RestoreDialog.RestoreDirectory = true;
if (RestoreDialog.ShowDialog() == DialogResult.OK) {
// Clear the DataSet
dsCats1.Clear();
//. dsCats1.Tables.Clear();
// Load the DataSet
dsCats1.ReadXml(RestoreDialog.FileName);
}
}
If you uncomment the line with the "//." it doesn't hang but the Typed DataSet dsCats1 is not usable as a Typed DataSet, only as an Untyped DataSet. I know this from the run time errors. I have also tried AccepChanges() and Update() on all of the Table DataAdapters but they have NO effect on either the DataSet or the Database itself???
I have found a temporary solution: I do the XMLRead on a second Typed DataSet (dsc) and merge into the cleared DataSet (dsCats1.) I haven't tested the whole thing yet but so far so good.
The XML file is about 5MB.
"Val Mazur" wrote:
> Hi Ray,
>
> Could you post your code here? What is the size of the saved XML file?
>
> --
> Val Mazur
> Microsoft MVP
>
>
> "Ray Stevens" <RayStevens@discussions.microsoft.com> wrote in message
> news:9B95A85D-8BFF-4FAC-9D22-147877FE93F0@microsoft.com...
> >I have a database with 5 tables loaded into a DataSet. I can do a WriteXML
> >OK but when I try to clear the DataSet and reload it with the XML file it
> >hangs during the ReadXML (This program is not responding.) If I clear the
> >Tables it comes back but the DataSet is empty of data but contains the
> >table names.
> >
> > TIA,
> > Ray Stevens
> >
>
>
>
- Next message: Patrick Bates: "Re: Persisted Recordsets"
- Previous message: Alan: "Re: SQL Server connectivity"
- In reply to: Val Mazur: "Re: Backup and restore a DataSet connected to MSDE2K with XML"
- Messages sorted by: [ date ] [ thread ]