7,762
社区成员
发帖
与我相关
我的任务
分享
dim rs As new Recordset
dim rscount as long
dim id as long
rs.open "select count(id) as c from Inventory", conn, 3, 1
rscount = rs!c
rs.close
rs.open "select id as c from Inventory", conn, 3, 1
id = rs!id
rs.close
msgbox "供 " & rscount & " 条记录,第一条记录的 ID 为" & id
rs.open "select count(id) as c from Inventory", conn, 3, 1
rscount = rs!c
rs.close
if rscount>=1 then
progressbar1.max = rscount
rs.open "select id,title as c from Inventory", conn, 3, 1
for i=1 to rscount
doevents
list1.additem rs!id & " " & rs!title
progressbar1.value = i
if i<rscount then rs.movenext
next i
rs.close
end if
Private Sub Command3_Click()
Dim conn As New ADODB.Connection
Dim strc As String
strc = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=erp;Data Source=127.0.0.1"
conn.Open strc
Dim strsql As String
strsql = "select * from Inventory "
'Dim rs As New ADODB.Recordset
'With rs
Dim WithEvents rs As ADODB.Recordset
Set rs = New ADODB.Recordset
With rs
.CursorLocation = adUseClient
.Properties("Initial Fetch Size") = 2
.Properties("Background Fetch Size") = 4
Debug.Print "Start"
Debug.Print "Initial Fetch Size: " & _
.Properties("Initial Fetch Size")
Debug.Print "Background Fetch Size" & _
.Properties("Background Fetch Size")
.Open strsql, conn, , , adAsyncFetch
'.Open strsql, conn, adOpenDynamic, adLockPessimistic, adCmdText
End With
'rs.Open strsql, conn, adOpenDynamic, adLockPessimistic, adCmdText
'End With
Text2(0).Text = rs.Fields(0)
End Sub
Private Sub Form_Load()
Me.WindowState = 2
End Sub
Private Sub rs_FetchProgress(ByVal Progress As Long, _
ByVal MaxProgress As Long, _
adStatus As ADODB.EventStatusEnum, _
ByVal pRecordset As ADODB.Recordset)
Debug.Print "fetch:" & Progress & "max:" & MaxProgress
End Sub