国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

VBS的數(shù)據(jù)庫操作類,

2024-07-21 02:15:39
字體:
供稿:網(wǎng)友
  • 本文來源于網(wǎng)頁設(shè)計愛好者web開發(fā)社區(qū)http://www.html.org.cn收集整理,歡迎訪問。
  • <!--
    蛙蛙推薦:vbs的數(shù)據(jù)庫操作類,這個類實現(xiàn)了平時主要的數(shù)據(jù)庫操作,因為我們天天都在和數(shù)據(jù)庫打交道,有時候用這樣一個類也挺方便的,但是不知道實用性怎么樣,因為在性能和錯誤處理方面沒有做很多考慮,所以不知道它的通用性如何.
    如果誰能再給這個類加上動態(tài)的錯誤處理的或者優(yōu)化一下性能,就更完美了.ps:做這個類也是為了練習一下vbs類的使用.
    -->
    <%
    class classado
    private conn_c
    private rs_c
    public strconn
    private sub class_initialize'定義類的初始化事件

    end sub

    private sub class_terminate ' 設(shè)置 terminate 事件。 '定義類的清空事件
    rs_c.close
    set rs_c=nothing
    conn_c.close
    set conn_c=nothing
    end sub

    public function opendb() '打開數(shù)據(jù)庫
    if isempty(strconn) then
    response.write("沒有設(shè)置數(shù)據(jù)庫連接字符串")
    response.end
    end if
    if isempty(conn_c) then
    set conn_c=server.createobject("adodb.connection")
    conn_c.open strconn
    else
    response.write("數(shù)據(jù)庫已經(jīng)打開了")
    response.end
    end if
    end function
    public function getrs(byval strsql) '獲取記錄集
    if isempty(conn_c) then
    opendb()
    end if

    set rs_c=server.createobject("adodb.recordset")
    rs_c.open strsql,conn_c,1,1
    set getrs=rs_c
    end function
    public function exesql(byval strsql) '執(zhí)行一條sql語句,用來插入,更新,刪除記錄
    if isempty(conn_c) then
    opendb()
    end if
    conn_c.execute(strsql)
    end function
    end class
    %>
    <%
    'on error resume next '調(diào)試程序的時候請把此句去掉
    strconn="driver={sql server};server=192.168.0.110;database=northwind;uid=sa;pwd=sa;"
    set c=new classado
    c.strconn=strconn
    c.opendb()
    strsql="select employeeid,titleofcourtesy + '' + lastname + '' + firstname as fullname from employees"
    arr_wawa=c.getrs(strsql).getrows()
    set rs=c.getrs(strsql)
    %>
    <table width="100%" border="0" cellspacing="1">
    <%
    if not rs.eof then
    for i=0 to rs.fields.count-1
    response.write rs.fields(i).name&"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
    next
    response.write "<br>"
    do while not rs.eof
    for i=0 to rs.fields.count-1
    response.write rs.fields(i).value&"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
    next
    response.write "<br>"
    rs.movenext
    loop
    end if
    %>
    <hr>

    <table width="100%" border="0" cellspacing="1">
    <% if not isempty(arr_wawa) then %>
    <% for i=0 to ubound(arr_wawa,2) %>
    <tr>
    <% for j=0 to ubound(arr_wawa,1) %>
    <td><%= arr_wawa(j,i) %></td>
    <% next %>
    </tr>
    <% next %>
    <% else %>
    <tr>
    <td>沒有記錄</td>
    </tr>
    <% end if %>
    </table>



    發(fā)表評論 共有條評論
    用戶名: 密碼:
    驗證碼: 匿名發(fā)表
    主站蜘蛛池模板: 伽师县| 南宫市| 太白县| 苍南县| 黎平县| 彝良县| 灌云县| 娄烦县| 宜宾县| 时尚| 凭祥市| 武强县| 东丽区| 桓台县| 南汇区| 永顺县| 缙云县| 台安县| 镇康县| 中西区| 巧家县| 抚州市| 泌阳县| 南江县| 伊宁市| 如东县| 长宁区| 隆子县| 贵州省| 遵义市| 双城市| 射洪县| 湘乡市| 武邑县| 虹口区| 海城市| 梅河口市| 鄢陵县| 潮州市| 通州区| 阿尔山市|