VB6程序怎么检测与SQL SERVER断开,并自动重连?
本帖最后由 thesky102 于 2013-09-28 12:18:20 编辑 我想了个办法,就是一分钟自动重连一次
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Form1_Load()
Set cnn = New ADODB.Connection
cnn.Open "Provider=SQLOLEDB.1;Password=123;Persist Security Info=false;User ID=sa;Initial Catalog=testdatabase;Data Source=computer"
Set rs = New ADODB.Recordset
End Sub
Private Sub Timer1_Timer()
rs.open ***************
*
*
*
*
rs.close
End Sub
Private Sub Timer2_Timer()
If rs.State = adStateOpen Then
rs.Close
End If
If cnn.State = adStateOpen Then
cnn.Close
End If
Set cnn = New ADODB.Connection
cnn.Open "Provider=SQLOLEDB.1;Password=123;Persist Security Info=false;User ID=sa;Initial Catalog=testdatabase;Data Source=computer"
Set rs = New ADODB.Recordset
End Sub