473,748 Members | 5,230 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Subselect from 2 tables from 2 different databases

Hi Folks,

I've been doing some research in this group and on the web but can't
seem to find the one clue that I'm looking for.

I have an ASP Page and need to join 2 tables from 2 different Access
databases. I can explain why 2 databases but it would just make this
a longer post so please just trust me.

I've gotten the following code to work fine:

-----------------------------
<%
'INTERNAL DB CONNECTION
dim strWWWRoot, strDBRoot, strDBName
strWWWRoot = server.mappath( "/")
strDBRoot = strWWWRoot & "\..\"
strDBName = "wwwroot/devel/customer-internal.mdb"
strConnectionSt ring = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source="
& strDBRoot & strDBName
Set internalconn = Server.CreateOb ject("ADODB.Con nection")
internalconn.Co nnectionString = strConnectionSt ring
internalconn.Op en
'EXTERNAL DATABASE CONNECTION Note: Althought I intialized this
connetion and opened it - I haven't actually figured out how to use
it.
strDBName2 = "wwwroot/devel/customer-external.mdb"
strConnectionSt ring2 = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source="
& strDBRoot & strDBName2
Set externalconn = Server.CreateOb ject("ADODB.Con nection")
externalconn.Co nnectionString = strConnectionSt ring2
externalconn.Op en
'Select Record
p = "SELECT A.CUST_NAME FROM CUST_TABLE A WHERE A.CUST_NAME IN (SELECT
B.NAME FROM [C:\inetpub\wwwr oot\devel\custo mer-external.mdb].ACCOUNT
B)"

Set rs = internalconn.Ex ecute(p)

%>
---------------------------

My question is this: How can I get this to work by referencing the
two connections (internalconn & externalconn) instead of having to
reference the physical path of the 2nd database
(C:\inetpub\www root\devel\cust omer-external.mdb)? I'd rather not
reference the physical path in case I change the name or something
down the road.

Thanks in advance for any help.
Mike G
Nov 13 '05 #1
1 3636
On 2 Jun 2004 15:41:47 -0700, mg****@hotmail. com (Mike Smith) wrote:

I don't think that's possible. One statement uses one connection.

One thing to try is to link tables from db2 into db1. That way you can
get away with only using conn1. Of course if db2 moves, the links are
invalid and need to be refreshed.

Alternatively write a thorough error handler, and notify the
Administrator via email if db2 is not found in its usual location.

-Tom.
Hi Folks,

I've been doing some research in this group and on the web but can't
seem to find the one clue that I'm looking for.

I have an ASP Page and need to join 2 tables from 2 different Access
databases. I can explain why 2 databases but it would just make this
a longer post so please just trust me.

I've gotten the following code to work fine:

-----------------------------
<%
'INTERNAL DB CONNECTION
dim strWWWRoot, strDBRoot, strDBName
strWWWRoot = server.mappath( "/")
strDBRoot = strWWWRoot & "\..\"
strDBName = "wwwroot/devel/customer-internal.mdb"
strConnectionS tring = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source="
& strDBRoot & strDBName
Set internalconn = Server.CreateOb ject("ADODB.Con nection")
internalconn.C onnectionString = strConnectionSt ring
internalconn.O pen
'EXTERNAL DATABASE CONNECTION Note: Althought I intialized this
connetion and opened it - I haven't actually figured out how to use
it.
strDBName2 = "wwwroot/devel/customer-external.mdb"
strConnectionS tring2 = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source="
& strDBRoot & strDBName2
Set externalconn = Server.CreateOb ject("ADODB.Con nection")
externalconn.C onnectionString = strConnectionSt ring2
externalconn.O pen
'Select Record
p = "SELECT A.CUST_NAME FROM CUST_TABLE A WHERE A.CUST_NAME IN (SELECT
B.NAME FROM [C:\inetpub\wwwr oot\devel\custo mer-external.mdb].ACCOUNT
B)"

Set rs = internalconn.Ex ecute(p)

%>
---------------------------

My question is this: How can I get this to work by referencing the
two connections (internalconn & externalconn) instead of having to
reference the physical path of the 2nd database
(C:\inetpub\ww wroot\devel\cus tomer-external.mdb)? I'd rather not
reference the physical path in case I change the name or something
down the road.

Thanks in advance for any help.
Mike G


Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2037
by: Karsten Hilbert | last post by:
Dear all, for some reason I just cannot get my brain wrapped around the required syntax for the following. I think I need to either use a join or subselect(s): Situation: ---------- I have two tables (simplified here) for an international medical office application (www.gnumed.org):
3
7202
by: Neil Zanella | last post by:
Hello, I would like to ask the about the following... PostgreSQL allows tables resulting from subselects to be renamed with an optional AS keyword whereas Oracle 9 will report an error whenever a table is renamed with the AS keyword. Furthermore, in PostgreSQL when the result of a subselect is referenced in an outer select it is required that the subselect result be named, whereas this is not true in Oracle. I wonder what standard SQL...
4
2749
by: James | last post by:
I have a performance problem with the following query and variations on the subselect. The EXISTS version of the first example will complete in ~10 minutes. The NOT logic in both the examples makes them both keep running long enough that a communications error is the only result returned so far. This is a federated view computer ~160 k rows, computer_sys_id is PK . matched_sware ~ 18 million no PK , no index. Any suggestions on...
3
12749
by: John Baker | last post by:
Hi: I just ran an Access application on someone elses system (With Access 2002). I made some changes (on his system) and then copied the program (data and program are still on the same file) onto a memory stick and put the whole package back on my system. I now have some tables I never had before, and cant get rid of them! They are MysysAccessObjects;MysysACEs;MysisObjects and a number of other tables with Mysis as the prefix. They are...
1
4207
by: Prakash RudraRaju | last post by:
Hi, I have recently migrated MSAccess Tables (nearly 120) to MySQL. To test successful migration I want to compare all tables. I have linked MySQL tables through ODBC connection. I want to create a report that compares all records between all tables in both databases. I am looking for a report with differences in number of records and differences in fields if 2 records are different. Probabaly it can be acheived through query, but I...
4
7562
by: dtwalter | last post by:
Is it possible to ORDER BY a SubSelect? I don't see why it wouldn't be, but I'm having some trouble. Hopefully it's just a simple error in syntax and somebody can tell me. Here's what I'm trying to do... I've got two tables: Table1: TestData Filename Bird FileB Blue FileA Circle FileC
2
7356
by: Morten K. Poulsen | last post by:
(re-post) Dear list, Please let me know if this is not the list to ask this kind of question. I am trying to optimize a query that joins two relatively large (750000 rows in each) tables. If I do it using a subselect, I can "force" the planner to choose the fastest path. Now, my question is:
2
4381
by: awebguynow | last post by:
Most JS people have seen sorttable.js and similar implementations. I'm trying to do a SubSelect of an existing table, restricting values in a Column to spec. range. Rows manipulated through sorttable are not copies of the row objects, they are ref's to the tbl row. Therefore care must be taken not to delete them if they are needed, etc. I'm getting used to the API: tbody.deleteRow(rowIndex)
4
4101
by: sganeshsvk | last post by:
sir, i want to store the same data values in two different databases at that same time in mysql using php programming. suppose any one databases data will lose then we use the other databases. suppose there is any query for store the same data values in two different databases at the same time. for eg: databases sample1
0
8830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9544
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8243
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.