After days of searching and trying different solutions, I give up and hope that someone can help me.
I have an Access 2007 database named
DB2023.accdb with several tables.
I created with ADOX a new empty database named
DB2024.accdb. Both are located in
C:\Temp.
With codebehind (using VB), I want to copy all tables and their columns (but without their data) from
DB2023 into
DB2024.
Of course, I can hard-code the creation, but hope there is a simpler way.
Looking forward to suggestions.
What I have tried:
Have not found any example for this explicit task. The closest I got, is
Dim Filename = "C:\Temp\DB2023.accdb"
Dim ConnString As String = _
"Provider=Microsoft.ACE.OLEDB.12.0; Data source =" & Filename
Dim cn As New OleDbConnection(ConnString)
Dim dbCmdInsert As New OleDbCommand
cn.Open()
Dim restrictions() As String = New String(3) {}
restrictions(3) = "Table"
Dim AllTables As DataTable = Nothing
AllTables = cn.GetSchema("Tables", restrictions)
GridView1.DataSource = AllTables
GridView1.DataBind()
Resulted in a table with
Table_Name
and
Table_Type
and creation/modifying data.
But how to get column data for each table?
I assume that
For EACH row as DataRow in Alltables.Rows
Next
is the way, but details??