Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Query problem

Status
Not open for further replies.

Damby

Programmer
Jan 29, 2002
13
0
0
CA
I Am trying to make a query, using ADODB, between two tables from two different DBs (.dbf) from two different directory.

I Have not found how to do it yet.

Some Help would be appreciated.

Thanks.

Damby
 
What type of database server are you using? I know in SQL Server you can join tables between two different database on the same server by including the database name in the query string.

Example:

select a.field1, b.field2
from database1.table1 a, database2.table1 b
where b.joinfield = a.joinfield

I am using "a" and "b" as aliases for the tables so they are easier to refer to elsewhere in the query, but you don't have to do that if you want to use the full reference each time.
 
I am using Dbase IV Databases with VB6.

The problem I am confronted with is that, with ADODB, we use connections. The way I understand it is, a connection is linked to a specific directory. With that connection, we can make query using recordset objects. To make those queries, we are confined to the directory with which the connection is linked.

The problem I have been confronted with is that I have another table from another DB located in another directory. I want to use that other table with a table from the first DB to make a query. I tried many different ways, but I keep getting an ODBC error because I am trying to link my query with that table located outside the connection directory.

I am used to the way Delphi 5 works which is that we don't work with connections but database and table ojects. It does not matter where the original table is located physically since we are working with the object. We can then make queries the way you explained it to me in your reply.

I have looked for a similar functionning in VB6 but haven't found anything. I understand, with your reply, that it does exist and it is possible. Some hints would be welcome.

Damby
 
Actually, the functionality you see in my reply is more a function of SQL Server (you can do the exact same thing in Query Analyzer entirely outside of VB). I'm afraid I don't have any experience with the database type you are using. If you can point me towards an "evaluation copy" of it or something I'd be glad to take a stab at it, though (always like expanding that skill set). ;)

I'll keep my eye out for any info on your problem. I wish I could help more. Good luck. I hope you find a solution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top