dim cnn as new adodc.connection cnn.connectionstring="......." cnn.open if cnn.state=adstateopen then msgbox "successful" else msgbox "unsuccessful" endif
代码连接比较麻烦(当然也可以),不过建议还是使用ADODC来测试,方便易用!!如: Dim conn As New Adodb.Connection conn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=try;Data Source=FLYTIGER" conn.Open If conn.State = adStateOpen Then MsgBox "successful" Else MsgBox "unsuccessful" End If
cnn.connectionstring="......."
cnn.open
if cnn.state=adstateopen then
msgbox "successful"
else
msgbox "unsuccessful"
endif
Dim conn As New Adodb.Connection
conn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=try;Data Source=FLYTIGER"
conn.Open
If conn.State = adStateOpen Then
MsgBox "successful"
Else
MsgBox "unsuccessful"
End If