2
Answers

Creating a table in VB.NET and Adding it to an Access Database

Scott Lenzi

Scott Lenzi

17y
3k
1

I am having problems adding a DataTable that I create in VB code into an Access Database.  Building the DataTable is quite easy, my problem lies within the creation of a  DataSet that I can add the DataTable to, in order to actually get the table into the Access Database.

This is about the extent of the help that I can get from the VB.NET help files…..

**********
Dim custDS As DataSet = New DataSet("CustomerOrders")

Dim ordersTable As DataTable = custDS.Tables.Add("Orders")

Dim pkCol As DataColumn = ordersTable.Columns.Add("OrderID", Type.GetType("System.Int32"))

ordersTable.Columns.Add("OrderQuantity", Type.GetType("System.Int32"))

ordersTable.Columns.Add("CompanyName", Type.GetType("System.String"))

 I can not find any specific help on how to create the DataSet itself.  All of the connection info that I can find is for retrieving data or modifying data in a database. I can not find any help on how to create a connection for adding tables. I suspect that an oledbcommand or oledbdataadapter or something of the sort is needed.  

Help!

Thank you so much for your time,
Scott911.

Answers (2)