Options
Optional. A ConnectOptionEnum value that determines whether this method should return after (synchronously) or before (asynchronously) the connection is established
asynchronous operation
An operation that returns control to the calling program without waiting for the operation to complete. Before the operation is complete, code execution continues. See also synchronous operation.
Private Sub conn_ConnectComplete(ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pConnection As ADODB.Connection)
Label1.Caption = "数据库连接成功!"
End Sub
Private Sub Form_Load()
Set conn = New ADODB.Connection
conn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=用户名;Initial Catalog=数据库名;Data Source=服务器名;pwd=密码", , , ADODB.ConnectOptionEnum.adAsyncConnect
End Sub