troubleshooting Question

How do I transfer one MS Access table into another MS Access Database using ADO/VB.NET

Avatar of DataMix
DataMix asked on
.NET ProgrammingVisual Basic.NET
14 Comments1 Solution1239 ViewsLast Modified:
Hello, here is my code; I have sucessfully made the two connection strings, dataAdapters etc...I also made a dataset which fills into a list box which gives me a visual confirmation that I am receiving data into my dataset from my first database connection string.  

The problem is I can't figure out for the life of me how to transfer that data into the other database.  I see alot of code out there but none of which I see is viable; i.e. it seems to be "Work arounds".

I got a majority of this figured out; I think; I just need to get the data from one database and put it into another Microsoft Access Database.

Thank you for what ever help any of you can offer.


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Dim conStr As String = "Provider=Microsoft.JET.OLEDB.4.0;data source=C:\Databases\SourceDatabase\.mdb"
        Dim strDest As String = "Provider=Microsoft.JET.OLEDB.4.0;data source=C:\Databases\DestDatabase.mdb"
        Dim sqlStr As String = "SELECT * FROM site"

        ' Create connection object
        Dim conn As OleDbConnection = New OleDbConnection(conStr)
        Dim conn2 As OleDbConnection = New OleDbConnection(strDest)

        ' Create data adapter object
        Dim da As OleDbDataAdapter = New OleDbDataAdapter(sqlStr, conn)
        Dim da2 As OleDbDataAdapter = New OleDbDataAdapter(sqlStr, conn2)

        ' Create a dataset object and fill with data using data adapter's Fill method
        Dim ds As DataSet = New DataSet
        da.Fill(ds, "site")

        ' Attach dataset's DefaultView to the datagrid control
        Dim dv As DataView = ds.Tables("site").DefaultView
        ListBox1.DataSource = dv
        ListBox1.DisplayMember = "sitename"

    End Sub
ASKER CERTIFIED SOLUTION
Howard Cantrell
retired

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 14 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros