Hi All
I am just starting learning C# and trying to do a simple excercise :
I have an Acess database from which I would like to extract all data from one table and write it to the XML file.
This is my code :
----------------------------------------------------------
1. Load a default file path int the textbox (txtFilePath) on the form :
private void Form1_Load(object sender, EventArgs e)
{
txtFilePath.Text=@"C:\Users\Acer User\Documents\Access Development\TestDbase.mdb";
}
-----------------------------------------------------------
2. Extract all data from Gilts_Details Access table and write to xml file
private void btnXML_Click(object sender, EventArgs e)
{
//access data source
string sCon = "Provider=Microsoft.Jet.OleDb.4.0;Data Source= " + txtFilePath;
OleDbConnection myConnection = new OleDbConnection(sCon);
//SQL COMMAND
string sSql = "SELECT * FROM [Gilts_Details]";
//CONNECT
OleDbDataAdapter myAdapter= new OleDbDataAdapter(sSql, myConnection);
//RETRIEVE DATA
DataSet myQueryData = new DataSet();
myAdapter.Fill( myQueryData);
//RETURN DATA TO XML FILE
string sXMLPath=@"C:\Users\Acer User\Documents\Visual Studio 2005\Projects\TestADO\TestADO\XmlFile.xml";
myQueryData.WriteXml(sXMLPath);
When i run this i get an oledbException error in that line :
myAdapter.Fill( myQueryData); with a comment "not a valid file name".
I have double checked and all the paths are correct.
Can anyone help?
Thank you
I am just starting learning C# and trying to do a simple excercise :
I have an Acess database from which I would like to extract all data from one table and write it to the XML file.
This is my code :
----------------------------------------------------------
1. Load a default file path int the textbox (txtFilePath) on the form :
private void Form1_Load(object sender, EventArgs e)
{
txtFilePath.Text=@"C:\Users\Acer User\Documents\Access Development\TestDbase.mdb";
}
-----------------------------------------------------------
2. Extract all data from Gilts_Details Access table and write to xml file
private void btnXML_Click(object sender, EventArgs e)
{
//access data source
string sCon = "Provider=Microsoft.Jet.OleDb.4.0;Data Source= " + txtFilePath;
OleDbConnection myConnection = new OleDbConnection(sCon);
//SQL COMMAND
string sSql = "SELECT * FROM [Gilts_Details]";
//CONNECT
OleDbDataAdapter myAdapter= new OleDbDataAdapter(sSql, myConnection);
//RETRIEVE DATA
DataSet myQueryData = new DataSet();
myAdapter.Fill( myQueryData);
//RETURN DATA TO XML FILE
string sXMLPath=@"C:\Users\Acer User\Documents\Visual Studio 2005\Projects\TestADO\TestADO\XmlFile.xml";
myQueryData.WriteXml(sXMLPath);
When i run this i get an oledbException error in that line :
myAdapter.Fill( myQueryData); with a comment "not a valid file name".
I have double checked and all the paths are correct.
Can anyone help?
Thank you