Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 3rd, 2004, 06:17 AM
Authorized User
 
Join Date: Jun 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Copy tables from one Access DB to Another

How do I do this in VB?

I'm not sure if this makes sense:
Here is my subroutine that does not currently work:

Public Sub DB_CopyTable(ByVal DBPathName$, ByVal TargetTable$, ByVal NewTableName$)
    cnxModelDB.Execute "SELECT " & TargetTable & ".* INTO " & TargetTable & " IN '" & DBPathName & "' From " & NewTableName
    Exit Sub
End Sub


BPathName - path to Target Database
TargetTable - Table Name from the Source Database BUT if this is the case, I'm not sure where I'd indicate the location of this source database...do I need to do something beforehand or put in the whole path???
NewTableName - New Name when copied to Target Database

I'm not sure if I should have the connection of the target DB or the source DB...I don't think it really matters though (?)

Please help! I just need to know the connections, and syntax needed to perform this operation before I create a recordset to query the target DB with all the tables included in it.

Thank you!
Maria

 
Old August 4th, 2004, 09:52 AM
Authorized User
 
Join Date: Jun 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This worked:

Public Sub DB_CopyTable(ByVal DBPathName$, ByVal TargetTable$, ByVal NewTableName$)
    If TargetTable = "TEDSSEQFN" Then
        cnxDEDSS.Execute "SELECT " & TargetTable & ".* INTO " & TargetTable & " IN '" & DBPathName & "' From " & NewTableName
    ElseIf TargetTable = "TEDSSBookmarks" Then
        cnxModelDB.Execute "SELECT " & TargetTable & ".* INTO " & TargetTable & " IN '" & DBPathName & "' From " & NewTableName
    Else
        cnxMacroLibrary.Execute "SELECT " & TargetTable & ".* INTO " & TargetTable & " IN '" & DBPathName & "' From " & NewTableName
    End If

    Exit Sub
End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
copy tables and stored procs between database lokey VB Databases Basics 1 March 5th, 2007 02:40 PM
creating tables within tables in access??? carswelljr Access 3 August 23rd, 2006 01:21 PM
Getting list of tables using DB name shazia1 VS.NET 2002/2003 2 July 6th, 2005 12:17 PM
Getting the a local copy of the Server DB Sappu SQL Server ASP 2 March 21st, 2005 12:27 PM
Copy Header and Details to similar tables Mitch Access 2 February 2nd, 2005 07:34 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.