- using System;
- using System.Data;
- using System.Data.OleDb;
-
- namespace FromDBToXML
- {
- /// <summary>
- /// Summary description for Class1.
- /// </summary>
- class FromDBToXML
- {
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void Main(string[] args)
- {
- //
- // TODO: Add code to start application here
- //
-
- try
- {
- Console.WriteLine("Connexion a la bd");
- OleDbConnection conn = new OleDbConnection(@"provider=Microsoft.Jet.OLEDB.4.0;Data Source=DB.mdb");
- Console.WriteLine("Execution de la commande");
- OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM Contacts",conn);
-
- DataSet ds = new DataSet("Ensemble des contacts");
- da.Fill(ds, "Contacts");
-
- Console.WriteLine("Creation du fichier xml");
- ds.WriteXml(@"c:\Contacts.xml");
- conn.Close();
- }
- catch(Exception exc)
- {
- Console.WriteLine(exc.Message);
- }
- }
- }
- }
using System;
using System.Data;
using System.Data.OleDb;
namespace FromDBToXML
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class FromDBToXML
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
try
{
Console.WriteLine("Connexion a la bd");
OleDbConnection conn = new OleDbConnection(@"provider=Microsoft.Jet.OLEDB.4.0;Data Source=DB.mdb");
Console.WriteLine("Execution de la commande");
OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM Contacts",conn);
DataSet ds = new DataSet("Ensemble des contacts");
da.Fill(ds, "Contacts");
Console.WriteLine("Creation du fichier xml");
ds.WriteXml(@"c:\Contacts.xml");
conn.Close();
}
catch(Exception exc)
{
Console.WriteLine(exc.Message);
}
}
}
}