Using Visual Studio 2005

By bdelacruz246 ·
Hi Everybody,

Does anybody know how to move an Access table from one database to another using VB in Visual Studio 2005? Below is the code that I used. Both the arrTable object array and the copyTable datatable does not work. It copies the object to the dataset but it does not save it to the other database that is the source of that dataset. Any help would be really good. I have been stuck with this code for more than a day now.

Dim table As DataTable
Dim copyTable As DataTable
?Dim arrTable(25) As Object
Dim x As Integer = 0
Dim z As Integer = 0

Dim item As ListViewItem
Dim checkedItems As ListView.CheckedListViewItemCollection = _

For Each item In checkedItems
arrList(z) = item.SubItems(0).Text
z = z + 1

myConnectionSource = New OleDb.OleDbConnection(strConnectionSource)

For Each table In CoaSfaDataSet2.Tables
If arrList(x) = table.TableName Then
?arrTable(x) = table.Copy()
copyTable = table.Copy()
x = x + 1
z = z - 1 : If z = 0 Then Exit For
End If
Next table

myConnectionSource = Nothing

MsgBox("Cannot proceed! {0}." + e.ToString(), MsgBoxStyle.OkOnly, "NOT SUCCESSFUL")
End Try

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

Have you...

by scott_heath In reply to Using Visual Studio 2005

Tried using the Microsoft Access COM Objects in your project? If you want to move it as an object instead of using SQL, this is where I would start. MSDN will have lovely descriptions of what everything does.

Collapse -

I do not know

by bdelacruz246 In reply to Have you...

how to add a reference to that from VS 2005. I searched the MSDN site and could not find the link. Thank you for taking the time to answer my question. I will definitely look into this.

Collapse -

Do you...

by scott_heath In reply to I do not know

Have office installed? When you add a reference click on the COM tab and scroll down to Microsoft Access XX Object Library.

And you are right MSDN doesn't have easily accessible docs on this. Basically you can create a new instance of the Access app using Microsoft.Office.Interop.Access.Application then go from there.

I would just use SQL though, it's probably going to be easier.

Collapse -

You are right...

by bdelacruz246 In reply to Do you...

I added a reference to Interop.Access and it is not easy at all. I searched and could not find a way to move or copy one table from one database to another. Thank you so much for your help though. I'll go with the SQL, but I will still keep on trying to learn more about adding and using the references.

Collapse -

It's weird...

by scott_heath In reply to You are right...

Because Microsoft normally documents so well on MDSN.

They do offer a book on programming Office in .NET, but I have no idea if it would even cover what you need.

Related Discussions

Related Forums