Click here to Skip to main content
15,880,469 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am writing this code, but there is some error which i don't understand, can any body please help me to get out of this problem.
C#
protected void Page_Load(object sender, EventArgs e)
{
  string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\abc\\My Documents\\Visual Studio 2005\\WebSites\\test\\App_Data\\test.mdb";
  OleDbConnection con = new OleDbConnection(connectionString);
  DataTable dt = new DataTable();
  //creating new connection to database Employee
  con.Open();
  //opening connection
  //assigning data to DataAdapter according to the query
  OleDbDataAdapter adpt = new OleDbDataAdapter("select * from emp", con);
  //filling dataset.
  adpt.Fill(dt);
  dt.WriteXml("test.xml");
  con.Close();
}
Thanks in advance.
Posted
Updated 5-Jul-11 0:22am
v2
Comments
Pete O'Hanlon 5-Jul-11 6:21am    
What's the error? Some error isn't particularly helpful.
Prerak Patel 5-Jul-11 6:22am    
Specify the exact error.
Joan M 5-Jul-11 6:25am    
you should specify a little bit more... where do the error appears (which line) and which error appears... This information would help us to help you...
sahabiswarup 5-Jul-11 6:37am    
dt.WriteXml("test.xml") InvalidOperationException was unhandled by user code
this is the error message
Wonde Tadesse 5-Jul-11 7:48am    
Try to specify a full file path like dt.WriteXml("c:\\test.xml")

Hope this[^]might help you.
 
Share this answer
 
If you are getting an InvalidOperationException, this means that one of the columns being serialized implements the interface IDynamicMetaObjectProvider but does not implement IXmlSerializable. There's very little you can do to circumvent this I'm afraid.
 
Share this answer
 
Comments
sahabiswarup 5-Jul-11 7:11am    
what is your suggestion? what should i do?
give the full xml file path

MIDL
dt.WriteXml("test.xml");

above line should be like this
MIDL
dt.WriteXml("C:\test.xml");


you can also go for full code:
http://www.authorcode.com/code-for-writing-xml-file-from-dataset-in-vb-net/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900