Fra Access til xml
Nogen der har nogle gode forslag/links til hvordan man henter noget data ud fra en access database og laver det om til xml ?har følgende kode som virker fint, men kunne godt tænke mig at resultatet blev lavet om til en xml fil eller noget andet som også er nemt at hente data ud fra.
using System;
using System.Data.OleDb;
class OleDbTest{
public static void Main()
{
//create the database connection
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\db1.mdb");
//create the command object and store the sql query
OleDbCommand aCommand = new OleDbCommand("select * from emp_test", aConnection);
try
{
aConnection.Open();
//create the datareader object to connect to table
OleDbDataReader aReader = aCommand.ExecuteReader();
Console.WriteLine("This is the returned data from emp_test table");
//Iterate throuth the database
while(aReader.Read())
{
Console.WriteLine(aReader.GetInt32(0).ToString());
}
//close the reader
aReader.Close();
//close the connection Its important.
aConnection.Close();
}
//Some usual exception handling
catch(OleDbException e)
{
Console.WriteLine("Error: {0}", e.Errors[0].Message);
}
}
}
