vb连接access数据库问题 急! 急!急!
PrivateSubCommand35_Click()DimsqlAsStringDimiAsIntegerDimjAsIntegerDimsj()AsStringOpe...
Private Sub Command35_Click()
Dim sql As String
Dim i As Integer
Dim j As Integer
Dim sj() As String
Open App.Path + "\dat\" + "yssj1.dat" For Input As #1
Input #1, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13
Close #1
sql = "select 外径(m),内径(m),重量(kg),传动比,(sqr((外径(m)*外径(m)+内径(m)*内径(m))/2)^2* 重量(kg))*传动比^2/a1^2 as 变位重量(kg) from 其它零部件"
LJ = "select 飞轮力矩,传动比,飞轮力矩*传动比/a1^2 as 变位重量(kg) from 其它零部件"
TL = "select 天轮直径,2*90*天轮直径^2 as 变位重量(kg) from 其它零部件"
Adodc5.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "D:\我的VB设计3\database\变位重量计算2.mdb;Persist Security Info=False"
Adodc5.RecordSource = sql
Adodc5.RecordSource = LJ
Adodc5.RecordSource = TL
Adodc5.Recordset.MoveFirst
Select Case Adodc5.Recordset.???
Case 1
eee = Adodc5.Recordset.Fields("变位重量(kg)")
Case 2
fff = Adodc5.Recordset.Fields("变位重量(kg)")
Case 3
ggg = Adodc5.Recordset.Fields("变位重量(kg)")
Case 4
hhh = Adodc5.Recordset.Fields("变位重量(kg)")
End Select
Adodc5.Recordset.MoveNext
End Sub
请各位高手帮帮忙吧,这段程序“???”填什么 如果不对的话 应该怎样编写 其思想就是将数据库的每一行中最后一列的数读出来?如能调试成功定再送20分,感激不尽! 展开
Dim sql As String
Dim i As Integer
Dim j As Integer
Dim sj() As String
Open App.Path + "\dat\" + "yssj1.dat" For Input As #1
Input #1, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13
Close #1
sql = "select 外径(m),内径(m),重量(kg),传动比,(sqr((外径(m)*外径(m)+内径(m)*内径(m))/2)^2* 重量(kg))*传动比^2/a1^2 as 变位重量(kg) from 其它零部件"
LJ = "select 飞轮力矩,传动比,飞轮力矩*传动比/a1^2 as 变位重量(kg) from 其它零部件"
TL = "select 天轮直径,2*90*天轮直径^2 as 变位重量(kg) from 其它零部件"
Adodc5.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "D:\我的VB设计3\database\变位重量计算2.mdb;Persist Security Info=False"
Adodc5.RecordSource = sql
Adodc5.RecordSource = LJ
Adodc5.RecordSource = TL
Adodc5.Recordset.MoveFirst
Select Case Adodc5.Recordset.???
Case 1
eee = Adodc5.Recordset.Fields("变位重量(kg)")
Case 2
fff = Adodc5.Recordset.Fields("变位重量(kg)")
Case 3
ggg = Adodc5.Recordset.Fields("变位重量(kg)")
Case 4
hhh = Adodc5.Recordset.Fields("变位重量(kg)")
End Select
Adodc5.Recordset.MoveNext
End Sub
请各位高手帮帮忙吧,这段程序“???”填什么 如果不对的话 应该怎样编写 其思想就是将数据库的每一行中最后一列的数读出来?如能调试成功定再送20分,感激不尽! 展开
展开全部
你在这里用Select Case 没有任何的意义
把
Adodc5.Recordset.MoveFirst
Select Case Adodc5.Recordset.???
Case 1
eee = Adodc5.Recordset.Fields("变位重量(kg)")
Case 2
fff = Adodc5.Recordset.Fields("变位重量(kg)")
Case 3
ggg = Adodc5.Recordset.Fields("变位重量(kg)")
Case 4
hhh = Adodc5.Recordset.Fields("变位重量(kg)")
End Select
Adodc5.Recordset.MoveNext
改成
Adodc5.Recordset.MoveFirst
for i = 1 to 4
if i=1 then eee = Adodc5.Recordset.Fields("变位重量(kg)")
if i=2 then fff = Adodc5.Recordset.Fields("变位重量(kg)")
if i=3 then ggg = Adodc5.Recordset.Fields("变位重量(kg)")
if i=4 then hhh = Adodc5.Recordset.Fields("变位重量(kg)")
Adodc5.Recordset.MoveNext
next i
把
Adodc5.Recordset.MoveFirst
Select Case Adodc5.Recordset.???
Case 1
eee = Adodc5.Recordset.Fields("变位重量(kg)")
Case 2
fff = Adodc5.Recordset.Fields("变位重量(kg)")
Case 3
ggg = Adodc5.Recordset.Fields("变位重量(kg)")
Case 4
hhh = Adodc5.Recordset.Fields("变位重量(kg)")
End Select
Adodc5.Recordset.MoveNext
改成
Adodc5.Recordset.MoveFirst
for i = 1 to 4
if i=1 then eee = Adodc5.Recordset.Fields("变位重量(kg)")
if i=2 then fff = Adodc5.Recordset.Fields("变位重量(kg)")
if i=3 then ggg = Adodc5.Recordset.Fields("变位重量(kg)")
if i=4 then hhh = Adodc5.Recordset.Fields("变位重量(kg)")
Adodc5.Recordset.MoveNext
next i
展开全部
Private Sub Command1_Click()
Dim abc
abc = Combo2.Text
Adodc1.RecordSource = "select * from test where " & Combo2.Text & " ='" & Combo1.Text & " ' "
Adodc1.Refresh
Label1.Caption = Adodc1.Recordset.Fields(Combo3.Text)
End Sub
我这是通过Combo2.Text 和Combo1.Text 的条件查找出对应的Combo3.Text列对应的值 并显示于Label1.Caption 几句话就可以解决
Dim abc
abc = Combo2.Text
Adodc1.RecordSource = "select * from test where " & Combo2.Text & " ='" & Combo1.Text & " ' "
Adodc1.Refresh
Label1.Caption = Adodc1.Recordset.Fields(Combo3.Text)
End Sub
我这是通过Combo2.Text 和Combo1.Text 的条件查找出对应的Combo3.Text列对应的值 并显示于Label1.Caption 几句话就可以解决
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
.Fields("天轮直径")
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询