473,699 Members | 2,485 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 3633
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
2033
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
7196
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
2748
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
12744
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
4203
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
7556
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
7350
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
4378
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
4098
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
8689
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9035
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...
1
8916
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8885
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5875
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
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2348
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.