VB 读取数据问题,请高手帮忙解决!
这是按钮的代码:DimguidAsIntegerDimconn1AsADODB.ConnectionDimrs1AsADODB.RecordsetSetconn2=New...
这是按钮的代码:
Dim guid As Integer
Dim conn1 As ADODB.Connection
Dim rs1 As ADODB.Recordset
Set conn2 = New ADODB.Connection
Set rs2 = New ADODB.Recordset
conn2.Open "provider = Microsoft.jet.OLEDB.4.0;data source=" & App.Path & "\mdb\HY.mdb"
sql2 = "select * from 华亿铝业 where years = '" & znian.Text & "' and mons = '" & znian1.Text & "' order by days"
rs2.Open sql2, conn2, 1, 3
If rs2.EOF Or rs2.BOF Then
Else
guid = rs2.RecordCount
MsgBox guid
End If
Set conn1 = New ADODB.Connection
Set rs1 = New ADODB.Recordset
conn1.Open "provider = Microsoft.jet.OLEDB.4.0;data source=" & App.Path & "\mdb\HY.mdb"
sql1 = "select * from 华亿铝业 where years = '" & znian.Text & "' and mons = '" & znian1.Text & "' order by days"
rs1.Open sql1, conn1, 1, 3
If rs1.EOF Or rs1.BOF Then
tishi2 = MsgBox("不存在" & znian.Text + "年" + znian1.Text + "月" & "信息!存入信息点确定,继续查询点取消!", vbOKCancel, "提示")
If tishi2 = vbOK Then
h4.Hide
h3.Show
Else
End If
Else
rs1.MoveFirst
For i = 0 To guid
If rs1.EOF Or rs1.BOF Then
Else
h5.xianshi.Text = h5.xianshi.Text + rs1.Fields("min") + "元" + "-" + rs1.Fields("max") + "元" + " 均价: " + rs1.Fields("jun") + "元 " + rs1.Fields("years") + "年" + rs1.Fields("mons") + "月" + rs1.Fields("days") + "日" + vbCrLf
rs1.MoveNext
End If
Next i
rs1.Close
conn1.Close
rs2.Close
conn2.Close
h4.Hide
h5.Show
End If
实在不明白为什么还是不按顺序。。。。
能解决问题,加分奖励
days是 年月日里的日数据 是长整行 是mdb
如果循环读取5个以内的数据就不会出错,超过5个就这样了
我追加奖赏了,请高手帮忙解决! 展开
Dim guid As Integer
Dim conn1 As ADODB.Connection
Dim rs1 As ADODB.Recordset
Set conn2 = New ADODB.Connection
Set rs2 = New ADODB.Recordset
conn2.Open "provider = Microsoft.jet.OLEDB.4.0;data source=" & App.Path & "\mdb\HY.mdb"
sql2 = "select * from 华亿铝业 where years = '" & znian.Text & "' and mons = '" & znian1.Text & "' order by days"
rs2.Open sql2, conn2, 1, 3
If rs2.EOF Or rs2.BOF Then
Else
guid = rs2.RecordCount
MsgBox guid
End If
Set conn1 = New ADODB.Connection
Set rs1 = New ADODB.Recordset
conn1.Open "provider = Microsoft.jet.OLEDB.4.0;data source=" & App.Path & "\mdb\HY.mdb"
sql1 = "select * from 华亿铝业 where years = '" & znian.Text & "' and mons = '" & znian1.Text & "' order by days"
rs1.Open sql1, conn1, 1, 3
If rs1.EOF Or rs1.BOF Then
tishi2 = MsgBox("不存在" & znian.Text + "年" + znian1.Text + "月" & "信息!存入信息点确定,继续查询点取消!", vbOKCancel, "提示")
If tishi2 = vbOK Then
h4.Hide
h3.Show
Else
End If
Else
rs1.MoveFirst
For i = 0 To guid
If rs1.EOF Or rs1.BOF Then
Else
h5.xianshi.Text = h5.xianshi.Text + rs1.Fields("min") + "元" + "-" + rs1.Fields("max") + "元" + " 均价: " + rs1.Fields("jun") + "元 " + rs1.Fields("years") + "年" + rs1.Fields("mons") + "月" + rs1.Fields("days") + "日" + vbCrLf
rs1.MoveNext
End If
Next i
rs1.Close
conn1.Close
rs2.Close
conn2.Close
h4.Hide
h5.Show
End If
实在不明白为什么还是不按顺序。。。。
能解决问题,加分奖励
days是 年月日里的日数据 是长整行 是mdb
如果循环读取5个以内的数据就不会出错,超过5个就这样了
我追加奖赏了,请高手帮忙解决! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询