MySQL Select 语句返回记录集数量-1?
我在用VB访问MySQL的时候,
Set MySqlDB = New ADODB.Connection
Dim Sdb As String
Sdb = "DRIVER={MySQL ODBC 3.51 Driver}; " & "SERVER=10.20.5.25; " & "DATABASE=fudanproject_new; " & "UID=root;PWD=123;OPTION=3;PORT=3306 "
MySqlDB.Open Sdb
Dim strsql As String
strsql = "select * from users "
Dim rdSet As New ADODB.Recordset
Set rdSet = New Recordset
rdSet.Open strsql, MySqlDB, 1, 1
Dim i As Integer
If Not rdSet Then
cmbUser.Clear
With rdSet
For i = 0 To .RecordCount - 1
cmbUser.AddItem (Trim(.Fields!taskID))
.MoveNext
Next i
End With
End If
这时,rdSet.RecordCount为-1,这是怎么回事呢?
------解决方案--------------------Dim rdSet As New ADODB.Recordset
rdSet.CursorLocation=adClient
这样试试.
------解决方案--------------------必须配置。