views:

152

answers:

0

Hello All,

I have a dataset (from an XML file), I want to read the schema and values from this dataset and copy it into an access table.

I want to create the access database on fly (can use ADOX), create an access table (from ADOX) create the schema in this table and copy the values from dataset into this table.

I am getting an error when i try to create the table and add columns in it, Below is the code snippet which is giving me an error

      DataSet ds = new DataSet();
      Console.Write("The NAME IS" + FileName.Text.ToString());
      ds.ReadXml("FILE_PATH" + FileName.Text.ToString());


      ADOX.Catalog cat = new Catalog();
      cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='DATABASE_NAME';Jet OLEDB:Engine Type=5");

      Table tab = new Table();
      tab.Columns.Append("Column Name", DataTypeEnum.adVarChar, 50);

// I am inserting 32 more columns in this manner

      cat.Tables.Append(tab);

When I run this code block I get COM Exception : "TableID is invalid".

Am I trying to do this with a right approach? How can I copy the values from dataset to this table?

Thanks,

Sid