'在access数据库,建表test_table,并创建两字段(name,id),两字段均为数字型
Sub main
' Declarations
'
Dim destination(1 To 50, 1 To 125) As Variant
Dim prompt As integer
Dim retcode as Variant
Dim query as String
Dim outputStr as String
dim i,j as integer
dim sumstring as string
'打开数据库
' Open the datasource "SblTest"
'connection = SQLOpen("DSN=testpool; UID=root; PWD=111111")
'action1 = 1 ' Get the names of the ODBC datasources
'retcode = SQLGetSchema(connection:=connection,action:=1, qualifier:=qualifier, ref:=datasources())
'msgbox retcode
' Close the datasource connection
'查询数据库
query = "select * from test_table"
retcode = SQLRequest("DSN=testpool;UID=root; PWD=111111",query,outputStr,prompt,0,destination())
msgbox retcode
for i=1 to 2
for j=1 to retcode
sumstring=cstr(destination(i,j))
msgbox sumstring
'msgbox destination(i,j)
next j
next i
retcode = SQLClose(connection)
End Sub
'query = "select * from class"
'retcode = SQLRequest("DSN=SBLTESTW;UID=DBA;PWD=SQL",query,outputStr,prompt,0,destination())
'End Sub
' The following will open the datasource SBLTESTW and execute the query
' specified by query and return the results in destination
'