数据库查询,请指点,谢谢!

baoyufu 2011-09-26 03:44:11


strSql = "select playdate,playtime,name from result where sampleid = '" & Trim(grdSample.TextMatrix(i, 9)) & "'"
Set rcdBuf1 = New ADODB.Recordset
rcdBuf1.CursorLocation = adUseClient
rcdBuf1.Open strSql, gADOConnection, , adLockReadOnly
If Not (rcdBuf1.EOF And rcdBuf1.BOF) Then
For j = 6 To rcdBuf1.RecordCount - 1
mysheet.Rows(j).Insert
mysheet.Cells(j, 5).Value = rcdBuf1("playdate")
mysheet.Cells(j, 6).Value = grdSample.TextMatrix(i, 2)
mysheet.Cells(j, 7).Value = grdSample.TextMatrix(i, 3)
mysheet.Cells(j, 8).Value = rcdBuf1("playtime")
mysheet.Cells(j, 10).Value = rcdBuf1("name")
Next j
End If


我输出的都是rcdBuf1里的第一条记录,哪里出问题了,哪位大哥给指点下,小弟卡壳了,谢谢!
...全文
72 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
baoyufu 2011-09-26
  • 打赏
  • 举报
回复
谢谢3楼的提醒,解决了

For j = 0 To rcdBuf1.RecordCount - 1
mysheet.Rows(j + 6).Insert
mysheet.Cells(j + 6, 5).Value = rcdBuf1("playdate")
mysheet.Cells(j + 6, 6).Value = grdSample.TextMatrix(i, 2)
mysheet.Cells(j + 6, 7).Value = grdSample.TextMatrix(i, 3)
mysheet.Cells(j + 6, 8).Value = rcdBuf1("playtime")
mysheet.Cells(j + 6, 10).Value = rcdBuf1("name")
If Not rcdBuf1.EOF Then
rcdBuf1.MoveNext
End If
Next j

baoyufu 2011-09-26
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 wallescai 的回复:]
Next j
rcdBuf1.movenext '中间加上这一句, 移动到下一条记录.
End If
[/Quote]
谢谢提醒,居然是忘记了这句
熊孩子开学喽 2011-09-26
  • 打赏
  • 举报
回复
Next j
rcdBuf1.movenext '中间加上这一句, 移动到下一条记录.
End If

Athrun_w 2011-09-26
  • 打赏
  • 举报
回复
一边完成后要 dispose 以下。。。。
baoyufu 2011-09-26
  • 打赏
  • 举报
回复
怎么没人呀

7,759

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧