TA的每日心情 | 奋斗 2022-7-13 15:22 |
---|
签到天数: 1 天 连续签到: 1 天 [LV.1]测试小兵
|
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' 设置连接数据库所需要的初始值,包括:
' conn :数据库连接字符串
' sql:查询的SQL语句
' res:查询的返回记录
Dim conn,sql,res
conn="rovider=MSDASQL.1ersist Security Info=False;Data Source=QT_Flight32"
sql="select * from Orders"
Set res=nothing
' 调用外部子程序 OpenDB 进行连接数据库
OpenDB conn,sql,res
'msgbox res.RecordCount&"行," & res.fields.count & "列"
res.MoveFirst
' res.MoveNext 没有它的话,记录就成了死循环
'reporter.ReportEvent 2,"测试连接数据库","数据库获取数据:" & res.fields(0)
RowCount=res.RecordCount
ColumnCount=res.fields.count
While not res.eof
Record=""
For i=0 to ColumnCount-1
Record=Record & ":" &res.fields(i)
Next
Record=mid(Record,2)
reporter.ReportEvent 2,"数据库记录:",Record
res.MoveNext
Wend
' 调用外部子程序 CloseDB关闭数据库
CloseDB |
|