开发者

Copy from dataset to access table in C#?

I have a dataset (from an XML file), I want to read the sche开发者_如何学JAVAma 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?


Could you try to assign a name to the table?

tab.TableName = "MyName";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜