每当用 ADO 对象去连接远程数据库时,整个工程会停止在那里,有什么办法可以解决这个问题吗?

解决方案 »

  1.   

    用异步连接
    connection.Open ConnectionString, UserID, Password, OptionsOptions 
    Optional. A ConnectOptionEnum value that determines whether this method should return after (synchronously) or before (asynchronously) the connection is establishedasynchronous operationAn 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.
      

  2.   

    致gmc007(江西的佬表):
    能不能用中文解释一下,还有我用是的 RecordSet 的,应该如何设置呢?
      

  3.   

    Private WithEvents conn As ADODB.ConnectionPrivate Sub conn_ConnectComplete(ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pConnection As ADODB.Connection)
       Label1.Caption = "数据库连接成功!"
    End SubPrivate 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
      

  4.   

    多谢楼上两位,我再研究研究  RecordSet 的异步连接方法。
      

  5.   

    停在那是因為數據太多。用DoEvents
      

  6.   

    请问楼上在连接数据库时怎么用DOEVENTS?
    正确方法是异步连接!
      

  7.   

    用异步,写个dll,我有个例子,是关于煮咖啡的,要不要?如要,给我发消息。