Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Testing SQL Connection
Message
From
24/12/2003 01:42:37
 
 
To
23/12/2003 12:56:11
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Miscellaneous
Thread ID:
00861689
Message ID:
00861850
Views:
20
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
Previous
Reply
Map
View

Click here to load this message in the networking platform