我需要的就是一些代码。数据库我已经连接好了,就是不知道怎么提取出数据来赋值给一定的变量。我是用下面的语句来连接的。 Option Explicit Dim RS As New ADODB.Connection Dim CN As String Private Sub Form_click() CN = "provider =microsoft office 12.0 access database engine ole db provider;data source=d:\我的文档\AU系列螺旋桨回归系数.accdb;" RS.Open CN If RS.State = adStateOpen Then MsgBox "success" Else MsgBox "failure" End If Dim k As Double, i As Integer, j As Integer RS.Execute "select Aijk from AU型3叶桨Aijk回归系数 where n=1" ’运行时就这一句有问题 k = RS.RecordCount '我想把查询到的数据赋值给新变量K,可就是这句我知道通过什么方法,代码来实现 Print k Set RS = Nothing End Sub 请帮帮忙吧
RS.RecordCount只是查询符合条件的条数。
返回记录集后:dim tmp while not rs.eof tmp=format(rs!Aijk) '这个就是你要的吧 debug.print tmp rs.movenext wend
Option Explicit
Dim RS As New ADODB.Connection
Dim CN As String
Private Sub Form_click()
CN = "provider =microsoft office 12.0 access database engine ole db provider;data source=d:\我的文档\AU系列螺旋桨回归系数.accdb;"
RS.Open CN
If RS.State = adStateOpen Then
MsgBox "success"
Else
MsgBox "failure"
End If
Dim k As Double, i As Integer, j As Integer
RS.Execute "select Aijk from AU型3叶桨Aijk回归系数 where n=1" ’运行时就这一句有问题
k = RS.RecordCount '我想把查询到的数据赋值给新变量K,可就是这句我知道通过什么方法,代码来实现
Print k
Set RS = Nothing
End Sub
请帮帮忙吧
while not rs.eof
tmp=format(rs!Aijk) '这个就是你要的吧
debug.print tmp
rs.movenext
wend
Dim RS As New ADODB.Connection
RS.open "select Aijk from AU型3叶桨Aijk回归系数 where n=1"
里面的这一句SQL语句怎么改啊,他怎么会说数据类型不一致,出问题啊