G
Guest
Hi,
I'm developing an Access database that has to import data from multiple
SQLBase databases into a new table. This is the function i wrote to do this:
Function updateODBC(Optional ByVal Database As Variant)
Dim cn As ADODB.Connection
Dim sSQL As String, sODBCString As String
If IsMissing(Database) Then Administratie = DEFAULT_DB
sODBCString = "ODBC;DSN=Unit 4 Multivers;DB=" & Database &
";SRVR=MVSERV;UID=ODBC;PWD=ODBC;"
Set cn = Application.CurrentProject.Connection
Debug.Print sODBCString
sSQL = "SELECT * INTO " & _
"[tblU4MGrootboek] " & _
"FROM " & _
"[" & sODBCString & "].[PUBLIC.GROOTBOEK];"
cn.Execute sSQL
cn.Close
Set cn = Nothing
End Function
Before i execute this function i delete the table 'tblU4MGrootboek'. The
first time i execute this function it works fine. Next time when i execute it
with a different database it imports the table from the first database!? It
looks like it doesn't refresh the ODBC connection and the connection to the
first database is still open and used.
Does anyone have a suggestion how i can resolve this behavior?
Thanx,
Dennis
I'm developing an Access database that has to import data from multiple
SQLBase databases into a new table. This is the function i wrote to do this:
Function updateODBC(Optional ByVal Database As Variant)
Dim cn As ADODB.Connection
Dim sSQL As String, sODBCString As String
If IsMissing(Database) Then Administratie = DEFAULT_DB
sODBCString = "ODBC;DSN=Unit 4 Multivers;DB=" & Database &
";SRVR=MVSERV;UID=ODBC;PWD=ODBC;"
Set cn = Application.CurrentProject.Connection
Debug.Print sODBCString
sSQL = "SELECT * INTO " & _
"[tblU4MGrootboek] " & _
"FROM " & _
"[" & sODBCString & "].[PUBLIC.GROOTBOEK];"
cn.Execute sSQL
cn.Close
Set cn = Nothing
End Function
Before i execute this function i delete the table 'tblU4MGrootboek'. The
first time i execute this function it works fine. Next time when i execute it
with a different database it imports the table from the first database!? It
looks like it doesn't refresh the ODBC connection and the connection to the
first database is still open and used.
Does anyone have a suggestion how i can resolve this behavior?
Thanx,
Dennis