Log in

View Full Version : Test connection SQL-server dB and Access



nkamp
01-01-2008, 12:02 PM
Hello,

From a existing application there is a connection between SQL-server dB and Access. The Access dB is filled by Linkt table and add-Query's.

What I want is before I start the query's I want to test the connection. If test is ok?, then execute the query. If it is not ok?, then make error message in logging and try x minutes later.

Is it simple possible to test a connection?

Thanks in advance,

Nico

Oorang
01-02-2008, 02:22 PM
What library ADODB, ADODB.NET, DAO, or RSO?

nkamp
01-03-2008, 01:12 PM
There is a reference made to Microsoft DAO 3.6 object library. So I think the DAO library is used. Maybe stupid, but I do not good understand this, because in the commands etc. are variable's defined with ADODB.

Two parts of code:


Dim db As DAO.Database
Dim qd As DAO.QueryDef
Set db = CurrentDb
Set grstReports = db.OpenRecordset("qrComboReports", dbOpenSnapshot, dbReadOnly, dbReadOnly)

But the commands etc. are defined with ADODB

Dim cmd As ADODB.Command
Dim rec As ADODB.Recordset
Dim strCommand As String

' initialiseer alle command's voor het uitvoeren van queries
Set cmd = New ADODB.Command
Set cmd.ActiveConnection = CurrentProject.Connection

etc.


Nico

Oorang
01-03-2008, 01:42 PM
Ah, then the answer would be both :-) Which connection are you wanting to test? (post code where it is made)