按照 duyhui(杜) 的思路检查了一下:定时器有段程序: Set Results2 = New ADODB.Recordset Results2.CursorLocation = adUseServer 但没有用Results2, 也没有调用Results2.Close。问题可能出在这里吧?总的程序结构如下:开始结束时,开关连接 Private Sub Form_Load() Dim ODBCName As String ODBCName = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;UID=root;PWD=;DATABASE=test;OPTION=0" Set MySQLConnection = New ADODB.Connection MySQLConnection.ConnectionString = ODBCName MySQLConnection.Open End SubPrivate Sub Form_Unload(Cancel As Integer) MySQLConnection.Close End Sub程序里会调用多个func,诸如此类:Sub Func1() Dim Results As ADODB.Recordset Dim SQLQuery As String Set Results1 = New ADODB.Recordset Results1.CursorLocation = adUseServer
SQLQuery = "select * from t1 where id=" & Str(x) Results1.Open SQLQuery, MySQLConnection If Results1.EOF Then SQLQuery = "insert into online values(" & Str(x) & "," & )" MySQLConnection.Execute SQLQuery Else SQLQuery = "update online set online=" & Str(x) & ", " where id=" & Str(x) MySQLConnection.Execute SQLQuery End If Results1.Close End Sub大家看没问题吧?
Set Results2 = New ADODB.Recordset
Results2.CursorLocation = adUseServer
但没有用Results2, 也没有调用Results2.Close。问题可能出在这里吧?总的程序结构如下:开始结束时,开关连接
Private Sub Form_Load()
Dim ODBCName As String
ODBCName = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;UID=root;PWD=;DATABASE=test;OPTION=0"
Set MySQLConnection = New ADODB.Connection
MySQLConnection.ConnectionString = ODBCName
MySQLConnection.Open
End SubPrivate Sub Form_Unload(Cancel As Integer)
MySQLConnection.Close
End Sub程序里会调用多个func,诸如此类:Sub Func1()
Dim Results As ADODB.Recordset
Dim SQLQuery As String
Set Results1 = New ADODB.Recordset
Results1.CursorLocation = adUseServer
SQLQuery = "select * from t1 where id=" & Str(x)
Results1.Open SQLQuery, MySQLConnection
If Results1.EOF Then
SQLQuery = "insert into online values(" & Str(x) & "," & )"
MySQLConnection.Execute SQLQuery
Else
SQLQuery = "update online set online=" & Str(x) & ", " where id=" & Str(x)
MySQLConnection.Execute SQLQuery
End If Results1.Close
End Sub大家看没问题吧?