|
![]() |
名片设计 CorelDRAW Illustrator AuotoCAD Painter 其他软件 Photoshop Fireworks Flash |
|
<% class classado Private conn_c Private rs_c Public strconn Private Sub Class_Initialize\\\'定义类的初始化事件 End Sub Private Sub Class_Terminate \\\' 设置 Terminate 事件。 \\\'定义类的清空事件 rs_c.close set rs_c=nothing conn_c.close set conn_c=nothing End Sub Public Function opendb() \\\'打开数据库 if isempty(strconn) then response.Write("没有设置数据库连接字符串") response.end end if if isempty(conn_c) then Set conn_c=Server.CreateObject("ADODB.Connection") conn_c.open strconn else response.Write("数据库已经打开了") 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) \\\'执行一条sql语句,用来插入,更新,删除记录 if isempty(conn_c) then opendb() end if conn_c.execute(strsql) End Function end class %> <% \\\'on error resume next \\\'调试程序的时候请把此句去掉 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&" " next response.write "<br>" do while not rs.eof for i=0 to rs.fields.count-1 response.write rs.fields(i).value&" " 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> 返回类别: 教程 上一教程: VBSCRIPT错误代码及对应解释大全 下一教程: 去除空格的函数 您可以阅读与"VBS的数据库操作类"相关的教程: · 使用组件封装ASP的数据库操作 · Access数据库操作中出现的怪现象 · ASP安全写入数据库操作,正常读出并显示在不同的场合 · 如何做一个高效的ASP数据库操作程序 · ASP中数据库操作中游标和加锁方法 |
![]() ![]() |
快精灵印艺坊 版权所有 |
首页![]() ![]() ![]() ![]() ![]() ![]() ![]() |