getConnection() in Vb and Access

getConnection() in Vb and Access

Post by Nagi Peter » Tue, 26 Nov 2002 20:40:39


I want to share some function in bas file with a project in vb and access.
BackendDb is a MySql Database.

In Access a opened a connection like this: sql, CurrentProject.Connection, ...
In VB:
set Conn = new ADODB.Connection connStr, usr, pwd sql, conn, ...

Now a want to share this code a wrote a function:
Function getConnection() as ADODB.Connection
        On Error Resume Next
        getConnection = CurrentProject.Connection
        if err > 0 the
                set getConnection = new ADODB.Connection
       connStr, usr, pwd
        end if
end function

In VB: sql, getConnection(), ...
works fine.
But in Access i think getConnection() is NULL
and I got an Error:
3709: Connetion can't be used, it's closed or unuseable in here.

Who is it possible to write a Function that returns the correct connection
in both projects?

Thanks for help



1. getConnection() for distributed Access?

I would like to make a JDBC connection to an MS Access97 database on a
remote NT computer.  I have working code to do the same thing for an
Oracle DB, but its DriverManager.getConnection() parameter is
different.  How do I do this for a remote Access database?

works (remote Oracle DB):
    con =

"joe", "passwd");

works (local Access DB):
    con = DriverManager.getConnection("jdbc:odbc:Conservs");

Can anyone tell me how to make this connection to a remote Access


2. Somebody, HELP to catch the ghost!Somebody, HELP to catch the ghost!

3. Simple getConnection Question with MS Access

4. sql query

5. VB + Access : How to insert and image into Access from VB

6. Printing script line-numbers in 5.0???

7. HELP: VB + Access : Trying to insert an image into Access from VB

8. Importing QueryDefs from Access

9. Migrate VB/Access to VB/Access/SQL Server?

10. Oracle JDBC problem with getConnection

11. getting error during getConnection

12. DriverManager.getConnection Synchronized

13. timeout when calling DriverManager.getConnection()