Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Testing SQL Connection
Message
De
24/12/2003 01:42:37
 
 
À
23/12/2003 12:56:11
Information générale
Forum:
Visual Basic
Catégorie:
Bases de données DAO/RDO/ODBC/ADO
Divers
Thread ID:
00861689
Message ID:
00861850
Vues:
18
I dont think you need to use APIs for that. there are various other ways, one is ..
Use ADO (ex: by setting reference to microsoft activeX data object 2.5 library)
declare a connection object
'put a error handler
on error goto cnnErr
dim cnn As New ADODB.Connection
'if you are using ODBC / DSN based connection use following
cnn.open "dsn=dsnName;uid=username;pwd=thepassword;database=urdatabase"
'if you are using OLE DB / DSN less connection use following
cnn.open "driver={SQL Server};server=urServer;uid=username;pwd=thepassword;database=urdatabase"
cnnErr:
msgbox "unable to connect to database"
You can also check the state of the connection by state property of connection
if cnn.state=adstateClosed then
msgbox "could not open connection"
else ' i.e. adStateOpen
'connction is open
end if
Best Luck..
Nilesh
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform