I
Ivan Grozney
I have a database that needs to connect to two databases on two different
servers. Security and the DBA doesn't want to make a linked server is the
reason for this mess.
The db servers are PCs with SQL Express and MSDE. They are not members of
our domain so I have local SQL accounts on each of them so I can connect.
Well, I can connect with a DSN but every time they close it down they need to
remember the passwords to reconnect. Ugh! So I would like to code the
connections into my VBA and when I distribute the MDE (or whatever it is in
A2K7) they cannot get to the password.
Immediately after the connections I run some queries that get data from both
systems to combine in some reports. But I cannot get the strings to work.
Here are two things that I have tried. This is my first try into this so I
am sure I am missing something (everything??) in getting this to work...
#1
Dim db2 As DAO.Database
Dim rst2 As DAO.Recordset
Dim strConnect2, strSQL3 As String
strConnect = "ODBC;Driver=SQL Server;Server=10.74.4.128; " & _
"Database=LIVEDATABASE;UID=FNLReader;PWD=r#adTSA"
strSQL3 = "SELECT * FROM [" & strConnect & "].Badge WHERE FALSE"
Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL3, dbOpenSnapshot)
#2
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strConnect, strSQL1 As String
strConnect = ODBC;DSN=ArtCA;SRVR=X.X.X.X;UID=UName;Pwd=PWD"
Set db = OpenDatabase("LBASE", dbDriverNoPrompt, False, strConnect)
strSQL1 = ""
strSQL1 = strSQL1 & "INSERT INTO dbo_..."
strSQL1 = strSQL1 & "WHERE BO.ZZZ Is Null;"
CurrentDb.Execute strSQL1, dbFailOnError + dbSeeChanges
TIA
Vanya
servers. Security and the DBA doesn't want to make a linked server is the
reason for this mess.
The db servers are PCs with SQL Express and MSDE. They are not members of
our domain so I have local SQL accounts on each of them so I can connect.
Well, I can connect with a DSN but every time they close it down they need to
remember the passwords to reconnect. Ugh! So I would like to code the
connections into my VBA and when I distribute the MDE (or whatever it is in
A2K7) they cannot get to the password.
Immediately after the connections I run some queries that get data from both
systems to combine in some reports. But I cannot get the strings to work.
Here are two things that I have tried. This is my first try into this so I
am sure I am missing something (everything??) in getting this to work...
#1
Dim db2 As DAO.Database
Dim rst2 As DAO.Recordset
Dim strConnect2, strSQL3 As String
strConnect = "ODBC;Driver=SQL Server;Server=10.74.4.128; " & _
"Database=LIVEDATABASE;UID=FNLReader;PWD=r#adTSA"
strSQL3 = "SELECT * FROM [" & strConnect & "].Badge WHERE FALSE"
Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL3, dbOpenSnapshot)
#2
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strConnect, strSQL1 As String
strConnect = ODBC;DSN=ArtCA;SRVR=X.X.X.X;UID=UName;Pwd=PWD"
Set db = OpenDatabase("LBASE", dbDriverNoPrompt, False, strConnect)
strSQL1 = ""
strSQL1 = strSQL1 & "INSERT INTO dbo_..."
strSQL1 = strSQL1 & "WHERE BO.ZZZ Is Null;"
CurrentDb.Execute strSQL1, dbFailOnError + dbSeeChanges
TIA
Vanya