473,382 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

multiple database access

hi
i am using vb6 and i want to access two database in single query. both the databases are password protected. i want to select all records from first database which are not in the second database..
please help me..
Jan 24 '12 #1

✓ answered by Rabbit

Please use code tags when posting code.

I stand corrected, you can access other databases from the SQL engine.

However, with a secured Access database, you have to set other options because Access does not use the username and pwd sections of a connection string.

You need to use
Expand|Select|Wrap|Line Numbers
  1. ' Establish the location of the SYSTEM.MDA files if in another
  2.    ' directory other than the \WINDOWS directory:
  3.    SetDataAccessOption 1, "C:\MYDIR\MYAPP.INI"
  4.    ' Log on to a valid account:
  5.    SetDefaultWorkspace "admin", "<password>"
to set up the needed access.

Source: http://support.microsoft.com/kb/113701

Also, according to the source, the connection only needs to be set up with the path
Expand|Select|Wrap|Line Numbers
  1. [;database=C:\ACCESS\DB1.MDB]

5 3536
Rabbit
12,516 Expert Mod 8TB
You can't do it in one query. You'll have to use two recordsets and then compare both in code.
Jan 24 '12 #2
i did it in one single query without password proctected database. but i dont know how to write query for password protected databases.
the code is

Dim AdoConn As ADODB.Connection, AdoRSet As ADODB.Recordset
Dim AdoConn1 As ADODB.Connection, AdoRSet1 As ADODB.Recordset
Dim sCon As String
Dim AdoPassword As String
Dim AdoErr As Byte

AdoDatabasePath = App.Path & "\db.mdb"
AdoPassword = "xyz"
'CONNECTION STRING
sCon = "Provider=Microsoft.Jet.OLEDB.4.0;Password=;" & _
"User ID=Admin;Data Source=" & AdoDatabasePath & ";" & _
"Jet OLEDB:Database Password='" & AdoPassword & "'"
Set AdoConn = New ADODB.Connection
AdoConn.Open sCon

AdoDatabasePath = App.Path & "\db1.mdb"
sCon = "Provider=Microsoft.Jet.OLEDB.4.0;Password=;" & _
"User ID=Admin;Data Source=" & AdoDatabasePath & ";" & _
"Jet OLEDB:Database Password='" & AdoPassword & "'"
Set AdoConn1 = New ADODB.Connection
AdoConn1.Open AdoConn.Execute("select * from test")

qu = "select distinct(a.test) from test a where a.test not in (select * from [;database=" & AdoConn1 & "].test12 ) "

Set AdoRSet = AdoConn.Execute(qu)
Jan 25 '12 #3
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code.

I stand corrected, you can access other databases from the SQL engine.

However, with a secured Access database, you have to set other options because Access does not use the username and pwd sections of a connection string.

You need to use
Expand|Select|Wrap|Line Numbers
  1. ' Establish the location of the SYSTEM.MDA files if in another
  2.    ' directory other than the \WINDOWS directory:
  3.    SetDataAccessOption 1, "C:\MYDIR\MYAPP.INI"
  4.    ' Log on to a valid account:
  5.    SetDefaultWorkspace "admin", "<password>"
to set up the needed access.

Source: http://support.microsoft.com/kb/113701

Also, according to the source, the connection only needs to be set up with the path
Expand|Select|Wrap|Line Numbers
  1. [;database=C:\ACCESS\DB1.MDB]
Jan 25 '12 #4
please tell me how to specify password in [;database=C:\ACCESS\DB1.MDB] statement to connect with the second database.
Jan 26 '12 #5
Rabbit
12,516 Expert Mod 8TB
You don't, at least not through the connection string. You set it up using the options I posted before that.
Jan 26 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jenny Zhang | last post by:
Hi, I am running OSDL-DBT3 test against PostgreSQL. I found performance difference between the runs even though the data and queries are the same. I tried to study this problem by getting...
0
by: Fernando Nasser | last post by:
Multiple database services and multiple versions on Red Hat Linux systems The way it works is that we require a specific service script for each database service (that is listening on each port)....
1
by: intl04 | last post by:
Are there any problems with multiple user access to the same Access database on a shared network drive? I have 'shared' chosen for 'default open mode'. As for the record locking properties, I...
4
by: Shawn H. Mesiatowsky | last post by:
I have a strange problem here. I have my development computer with IIS installed, and we have a SQL server as well on a windows 2000 server. both are members of a domain. I have restricted access...
4
by: Val P | last post by:
How does everyone design the database access layer in an asp.net application? Two options that come to mind is: 1. create a database class and instanciate it as needed, local to a function or...
0
by: CountDraculla | last post by:
Fixing Multiple Database bug in adoDB popular data access layer for php, adoDB can support multiple databases from different provider at time, but not from same provider. what I mean is if you...
5
by: Mike TI | last post by:
May 2, 2006 Hi All I have been learning VB.Net 2005 by developing a small project. I have been using SQL Express till now. Now I have built a similar to SQL Data Base in MS Access. I...
3
by: vssp | last post by:
Hi friends In my application i need to connect multiple database.First i connect one database and got the value then i connect another database to insert the values . If any possible to two...
0
by: BEAR285 | last post by:
Greetings, I run a clan based website. I have 5 mysql databases but at this time only using one. I know how to load the data to the databases but I have a few questions that may sound quite stupid...
4
by: gamaz | last post by:
Hi, I am trying to work on a stored procedure that will work with multiple database. I have a prototype of multiple databases. Those are named as the following: ts2_aldkm_app, ts2_aldkp_app,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.