Results 1 to 8 of 8

Thread: Run Query Accross multiple DB's?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2002
    Location
    SE England
    Posts
    732

    Run Query Accross multiple DB's?

    Is it possible to run an update accross 2 databases?

    I need to open a text file using the MS Text driver, and run an update to an access database with the contents of the text file...

    NOTE: I can not open the text file in access or anything like that as this will run on a client machine which may not have access installed.. (just the jet drivers).
    Leather Face is comin...


    MCSD

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2002
    Location
    SE England
    Posts
    732
    ANYBODY???


    ^BUMP^
    Leather Face is comin...


    MCSD

  3. #3
    Fanatic Member Jerry Grant's Avatar
    Join Date
    Jul 2000
    Location
    Dorset, UK
    Posts
    810
    This should be possible, use something like the following:
    VB Code:
    1. Public Sub P_CopyTable( _
    2.                        ByVal strSourceDb As String, _
    3.                        ByVal strDestinationDb As String, _
    4.                        ByVal strTable As String _
    5.                        )
    6.  
    7.     Dim strSQL          As String
    8.     Dim wrkJet          As Workspace
    9.     Dim dbSource   As Database
    10.     On Error GoTo AppendErr
    11.  
    12.     ' Open Microsoft Jet workspace & Microsoft Jet database.
    13.     Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
    14.     Set dbSource = wrkJet.OpenDatabase(strSourceDb, , ,"Text")
    15.  
    16.    
    17.     strSQL = "SELECT [" & strTable & "].* " & _
    18.              "INTO [" & strTable & "] " & _
    19.              "IN '" & strDestinationDb & "' " & _
    20.              "FROM [" & strTable & "]"
    21.              
    22.     frmUdate.lblStatus(1).Caption = "Copying existing data from " & strTable
    23.     DoEvents
    24.    
    25.     dbSource.Execute strSQL
    26.    
    27.     dbSource.Close
    28.     wrkJet.Close
    29.    
    30.     Exit Sub
    31.    
    32. AppendErr:
    33.     If Err = 3078 Then Resume Next
    34.  
    35. End Sub
    TheThis is using DAO, but you should be able to be done with ADO with a few changes.
    Jerry Grant................tnarG yrreJ
    Website: <JG-Design></.net>
    Email: [email protected]
    Working towards a bug free world......
    (Not a Microsoft employee)

  4. #4
    Fanatic Member Jerry Grant's Avatar
    Join Date
    Jul 2000
    Location
    Dorset, UK
    Posts
    810
    Cough!

    Error correction...

    Use dbUseODBC instead of dbUseJet and ensure your Text file has a DSN...
    Jerry Grant................tnarG yrreJ
    Website: <JG-Design></.net>
    Email: [email protected]
    Working towards a bug free world......
    (Not a Microsoft employee)

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2002
    Location
    SE England
    Posts
    732
    Thanks..

    But what are you apssinf as teh detsination db?? a DSN name, or a connectionstsring? or a file name?
    Leather Face is comin...


    MCSD

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2002
    Location
    SE England
    Posts
    732
    Please jerry! : )
    Leather Face is comin...


    MCSD

  7. #7
    Fanatic Member Jerry Grant's Avatar
    Join Date
    Jul 2000
    Location
    Dorset, UK
    Posts
    810
    If But what are you apssinf as teh detsination db??
    Means But what are you passing as the destination db??

    A: The Path to the destination database

    I use routine as part of an application to convert a legacy Access 97 database with a bad schema design into a new Access 2000 database with a normalized schema.

    So in theory, it should work with a Text file as the source.

    Check the MSDN for exact syntax for these two formats.
    Jerry Grant................tnarG yrreJ
    Website: <JG-Design></.net>
    Email: [email protected]
    Working towards a bug free world......
    (Not a Microsoft employee)

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2002
    Location
    SE England
    Posts
    732
    Thanks,

    Sorry for the multiple typos...

    Wasnt concentrating.

    I got it working a treat!

    Leather Face is comin...


    MCSD

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width