Results 1 to 9 of 9

Thread: Select query on two databases

  1. #1

    Thread Starter
    Addicted Member parminder's Avatar
    Join Date
    Apr 2003
    Location
    India
    Posts
    168

    Select query on two databases

    Hi to all,

    Who can we run VB.NET's SELECT query on two MS-Access database. For example :

    There are two databases: Database1 and Database2
    There are two tables Table1 and Table2 from Database1 and Database2 respectively.
    Table1's field "Field1" and Table2's field "Field2" are for to store common object (datatype)

    Now how can I run the query like this:

    Select * from Table1,Table2 where Table1.Field1=Table2.Field2


    How it is possible in VB.net (ADO.NET)

    Thanks in Advance

  2. #2
    Addicted Member
    Join Date
    Feb 2002
    Location
    closed
    Posts
    196
    SQL is just SQL. Its not the preserve of VB.NET so anything you can query using SQL can be embedded in VB.NET code and executed.

    However you mention you will be querying from 2 databases in one SQL statement - make sure MS Access supports this concept. Table linking across domains is easy in Oracle (and i would imagine SQL Server)..not sure about Access

    Cheers...

  3. #3

    Thread Starter
    Addicted Member parminder's Avatar
    Join Date
    Apr 2003
    Location
    India
    Posts
    168
    Thanks powdir

    In one of thread "kleinma" told it is possible, but not mentioned how ? (His means was it is possible from two different data sources)

    I am interested in MS-Access.


    Thanks again

  4. #4
    Addicted Member
    Join Date
    Feb 2002
    Location
    closed
    Posts
    196
    yup - i completely forgot how easy it actually is to link tables in MS Access.

    FILE>GET EXTERNAL DATA>LINK TABLES

    you get a file chooser dialog from where you can choose the datasource to link to (*.mdb, ODBC etc)

    Access then creates a linking table (which you can browse like a local table) you can then query using standard SQL syntax

    Hope that helps - cheers

  5. #5

    Thread Starter
    Addicted Member parminder's Avatar
    Join Date
    Apr 2003
    Location
    India
    Posts
    168
    Thanks powdir again


    I have tried this type of solution in MS-Access and VB6. But it works only if these (MS-Access) files are not password protected.

    I will try it in MS-Access 2002 and in VB.net


    Thanks

  6. #6

    Thread Starter
    Addicted Member parminder's Avatar
    Join Date
    Apr 2003
    Location
    India
    Posts
    168
    in following thread "kleinma" mention this thing


    http://www.vbforums.com/showthread.p...hreadid=261644

  7. #7
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    I don't work much with .NET right now because at my current job we haven't even thought about deploying the .NET framework out to our systems. But they did send us to a seminar on it when .NET was being released and I remember them talking about it there... The below link is a reference for you to use

    http://msdn.microsoft.com/library/de...ngdatasets.asp

    DataSets are what is used to accomplish this.. they are sort of the successor to ADO Recordsets

    from this link
    The DataSet is independent of any specific data source and therefore can be populated from multiple and differing data sources including relational databases and XML, or can be populated with data local to the application.

  8. #8

    Thread Starter
    Addicted Member parminder's Avatar
    Join Date
    Apr 2003
    Location
    India
    Posts
    168
    Thanks kleinma


    I was thinking it is without DataSet, but the link give me what I wanted.

    Thanks

  9. #9
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    no problem....

    once I get into my new job next month, I will have .NET, so I will be working with it a lot more as well

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