欢迎光临
我们一直在努力

我是怎么写的,用vb编写dll从数据表中返回array(部分源代码),请大虾过目,希望斑竹能放进精华区

建站超值云服务器,限时71元/月

option explicit

private myerrobj as errorcls
private scriptingcontext as scriptingcontext
private request as request
private response as response
private server as server
private session as session
dim dbpath
dim dbprovider as string

public sub onstartpage(passedscriptingcontext as scriptingcontext)

set scriptingcontext = passedscriptingcontext
set request = scriptingcontext.request
set response = scriptingcontext.response
set server = scriptingcontext.server
set session = scriptingcontext.session
set myerrobj = new errorcls
dbpath = server.mappath("xx9601.mdb")

用odbc数据源进行连接
dbprovider = "dsn=xx9601;uid=;pwd="

dbprovider = "driver={microsoft access driver (*.mdb)};dbq=" & dbpath

end sub

public sub onendpage()

set scriptingcontext = nothing
set request = nothing
set response = nothing
set server = nothing
set session = nothing
set myerrobj = nothing

end sub

private function getall(adocnn as adodb.connection, scmd as string)

dim adors as adodb.recordset
dim arrayado()
dim ivar
dim jvar
    
on error resume next

set adors = new adodb.recordset

adors.open scmd, adocnn, 3, 1

if adocnn.errors.count > 0 or adors.eof then
    getall = null
    set adors = nothing
    exit function
end if

redim arrayado(adors.recordcount – 1, adors.fields.count – 1)

for ivar = 0 to adors.recordcount – 1
    for jvar = 0 to adors.fields.count – 1
        arrayado(ivar, jvar) = trim(adors.fields(jvar))
    next
    adors.movenext
next

set adors = nothing

vb6的数组赋值方式
getall = arrayado

end function

public function gettoary(pwd as integer, scmd as string)

if pwd <> 9601 then
    gettoary = null
    exit function
end if

建立数据库连接
dim adocnn as adodb.connection
set adocnn = new adodb.connection
adocnn.open dbprovider

gettoary = getall(adocnn, scmd)

adocnn.close
set adocnn = nothing

end function

public sub sqlexecout(opwd as integer, scmd as string)

if opwd <> 9601 then
    displayerr "密码错误!"
    exit sub
end if

建立数据库连接
dim adocnn as adodb.connection
set adocnn = new adodb.connection
adocnn.open dbprovider

sqlexec adocnn, scmd

adocnn.close
set adocnn = nothing

end sub

private sub sqlexec(adocnn as adodb.connection, scmd as string)

adocnn.execute scmd

end sub

private sub displayerr(errmsg as string)

dim myerrobj as errorcls

set myerrobj = new errorcls

myerrobj.displayerr errmsg, response

end sub

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 我是怎么写的,用vb编写dll从数据表中返回array(部分源代码),请大虾过目,希望斑竹能放进精华区
分享到: 更多 (0)