Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 3rd, 2004, 06:17 AM
Authorized User
 
Join Date: Jun 2004
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old August 4th, 2004, 09:52 AM
Authorized User
 
Join Date: Jun 2004
Location: , , .
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
Reply With Quote
Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
copy tables and stored procs between database lokey VB Databases Basics 1 March 5th, 2007 01: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 11:27 AM
Copy Header and Details to similar tables Mitch Access 2 February 2nd, 2005 06:34 PM



All times are GMT -4. The time now is 02:58 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.