|
|
Question : ODBC Auto Connect
|
|
I have a MS Access 97 DB that links Oracle tables via MS ODBC for Oracle driver. What happens now is whenever the user runs the Access DB a prompt comes up asking the user for loginID, password and server. I would like to have this connection established automatically. Something like this in the form_load event:
Dim db As Database, strCon As String strCon = "ODBC;DSN=mydsn;UID=myuserid;PWD=mypassword;SERVER=myserver;" Set db = OpenDatabase("", False, True, strCon)
'btw the above does not work
any suggestions? thanks in advance
|
Answer : ODBC Auto Connect
|
|
The Oracle tables must be relinked with connect string you eluded to in your question. Do it with code:
Here is a sub() I use...
Sub ConnectOutput(dbsTemp As Database, strTable As String, strConnect As String, strSourceTable As String)
Dim tdfLinked As TableDef
' Create a new TableDef, set its Connect and ' SourceTableName properties based on the passed ' arguments, and append it to the TableDefs collection. Set tdfLinked = dbsTemp.CreateTableDef(strTable)
tdfLinked.Connect = strConnect tdfLinked.Attributes = dbAttachSavePWD tdfLinked.SourceTableName = strSourceTable dbsTemp.TableDefs.Append tdfLinked Set tdfLinked = Nothing
End Sub
...and a usage example...
ConnectOutput CurrentDB, "accessTableName", _ "ODBC;DSN=MyORAODBCDSN;UID=user;PWD=password;LANGUAGE=us_english;", "oracleTableName"
Or use the linked Table Add-in, where you can refresh links as needed.
GL, K
|
|
|
|
|