Copy data from one Access DB to Another?
Copy data from one Access DB to Another?
Copy data from one Access DB to Another?
Copy data from one Access DB to Another?
Copy data from one Access DB to Another?
Copy data from one Access DB to Another? Copy data from one Access DB to Another? Copy data from one Access DB to Another? Copy data from one Access DB to Another? Copy data from one Access DB to Another? Copy data from one Access DB to Another? Copy data from one Access DB to Another? Copy data from one Access DB to Another?
Copy data from one Access DB to Another? Copy data from one Access DB to Another?
Copy data from one Access DB to Another?
Go Back  Xtreme Visual Basic Talk > > > Copy data from one Access DB to Another?


Reply
 
Thread Tools Display Modes
  #1  
Old 09-26-2013, 05:01 AM
Meridian2000 Meridian2000 is offline
Contributor
 
Join Date: Jul 2003
Location: London/England
Posts: 573
Default Copy data from one Access DB to Another?


Is there a way using VB.Net you can copy data from one DB to another, I have 2 Access databases with exactly the same Tables within, I'd like to use VB to update one database with the other, I believe INSERT INTO is the command I need, but I don't want to specify all the column names as there are many, has anyone got any code I can use to achieve this please?

What I've got so far is :

Code:
CopyTable("c:\shared\postcodes26-09-2013a.mdb", "postcodesandaddressesbt", "c:\shared\postcodes26-09-2013.mdb")


    Public Sub CopyTable(ByVal strFromDatabase As String, ByVal strTableName As String, ByVal strToDatabase As String)
        On Error GoTo errCopyTable
        Dim strSQL As String
        Dim dbConFromDatabase As ADODB.Connection

        'open connection from database
        dbConFromDatabase = New ADODB.Connection
        dbConFromDatabase.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strToDatabase & ";Persist Security Info=False"
        dbConFromDatabase.Open()

        strSQL = "insert INTO " & strTableName & " FROM " & strTableName & " IN '" & strFromDatabase & "';"
        dbConFromDatabase.Execute(strSQL)
        dbConFromDatabase.Close()

        dbConFromDatabase = Nothing
        Exit Sub
errCopyTable:
        MsgBox("Error in Sub CopyTable:" & Err.Description, vbOKOnly)
    End Sub
__________________
Bumshanka - May the seed of your loins be fruitful in the belly of your woman - The Young Ones

Last edited by Meridian2000; 09-26-2013 at 05:08 AM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Copy data from one Access DB to Another?
Copy data from one Access DB to Another?
Copy data from one Access DB to Another? Copy data from one Access DB to Another?
Copy data from one Access DB to Another?
Copy data from one Access DB to Another?
Copy data from one Access DB to Another? Copy data from one Access DB to Another? Copy data from one Access DB to Another? Copy data from one Access DB to Another? Copy data from one Access DB to Another? Copy data from one Access DB to Another? Copy data from one Access DB to Another?
Copy data from one Access DB to Another?
Copy data from one Access DB to Another?
 
Copy data from one Access DB to Another?
Copy data from one Access DB to Another?
 
-->