欢迎光临
我们一直在努力

COM组件中如何连接数据库-ASP教程,组件开发

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

/* written by jaron ,2003-05-10 */

/* 原出处:江都资讯网 http://www.jiangdu.net */

/* 转载请注明出处和保留此版权信息 */

/* 欢迎使用sitemanager网站管理系统 http://sitemanager.cnzone.net */

vb- 工程 -引用 – ado 2.0 ,建一个类db,工程名设为 sqlconn

以下是偶程序中的部分代码,大家有空可以试试

option explicit

public strerror as string

public conn as new adodb.connection

public rs as new adodb.recordset

public property get errorstring() as string

errorstring = strerror

end property

public function conn_open(strsqlservername, strsqldbusername, strsqldbpassword, strsqldbname)

dim strcon as string

set conn = new adodb.connection

on error goto errhandler:

strcon = "provider=sqloledb;server=" & strsqlservername & ";user id=" & strsqldbusername & ";password=" & strsqldbpassword & ";database=" & strsqldbname & ";"

conn.open strcon

errhandler:

strerror = "错误源:" & err.source & vbcrlf & "描述:" & err.description

exit function

end function

function getrootid(byval classid)

dim query

query = "select class_id,rootid from tblcategory where class_id=" & classid & ""

set rs = conn.execute(query)

if not (rs.eof and rs.bof) then

getrootid = rs("rootid")

else

getrootid = classid

end if

rs.close

set rs = nothing

end function

编译后,在asp中这样用

function getrootid(byval id) 获取根类id号

set s_db = server.createobject( "sqlconn.db")

s_db.conn_open strsqlservername,strsqldbusername,strsqldbpassword,strsqldbname

getrootid = s_db.getrootid(id)

set s_db=nothing

end function

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » COM组件中如何连接数据库-ASP教程,组件开发
分享到: 更多 (0)

相关推荐

  • 暂无文章