您的位置:首页技术开发ASP技巧 → asp使用activex组件实例一

asp使用activex组件实例一

时间:2004/11/7 4:04:00来源:本站整理作者:蓝点我要评论(0)

test.asp

以下内容为程序代码:








activex<a href="http://www.baidu.com/baidu?tn=sayyes&word=asp+组件" target="_blank" _href="http://www.baidu.com/baidu?tn=sayyes&word=asp+组件"><span class="unnamed8"><span style="color:#0000FF">组件</span></span></a>应用例子一



<%

'---------------------------------------------------------

'activex组件应用例子一

'读取sql server 7 pubs数据库中authors表并分页显示

'asp文件中负责调用并前台数据检验,这里主要指page参数

'该例子完全使用activex组件来完成功能,速度快,保密性好,但页面定制能力差

'jjx by 2000/4/15

'----------------------------------------------------------------



dim blnErrorif not isempty(request("page")) then



if not isnumeric(request("page")) then



response.write "参数错误!"



blnError=true



end ifend ifif not blnError then



dim objLoop



Set objLoop=Server.CreateObject("Performance.Loop")



objLoop.List()



Set objLoop=Nothingend if%>




vb loop class file创建一个performance activex dll项目,引用microsoft active

server pages library和Microsoft ActiveX Databae Object。



填加一个class,命名为loop[code]Option Explicit



Dim MyScriptingContext As ScriptingContextDim MyRequest As RequestDim MyResponse As Response



Sub OnEndPage()



Set MyResponse = Nothing



Set MyRequest = Nothing



Set MyScriptingContext = Nothing



End Sub



Sub OnStartPage(PassedScriptingContext As ScriptingContext)



Set MyScriptingContext = PassedScriptingContext



Set MyRequest = MyScriptingContext.Request



Set MyResponse = MyScriptingContext.Response







End Sub



Function List()







Dim con As New ADODB.Connection



Dim rs As New ADODB.Recordset







Dim i As Integer



Dim j As Integer



Dim intPage As Integer



Dim intPageSize As Integer



Dim intPageCount As Integer



Dim strScriptName As String



Dim intPos As Integer



Dim intFieldCount As Integer



strScriptName = MyRequest.ServerVariables("Script_Name")



intPos = InStrRev(strScriptName, "/")



If intPos <> 0 Then



strScriptName = Mid(strScriptName, intPos + 1)



End If







If IsEmpty(MyRequest("page")) Then



intPage = 1



Else



intPage = CInt(MyRequest("page"))



End If







intPageSize = 10











con.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=pubs;Data Source=

(local)"



rs.Open "select * from authors", con, adOpenStatic



intFieldCount = rs.Fields.Count



With MyResponse



.Write ""



If Not (rs.EOF And rs.BOF) Then



rs.PageSize = 10



rs.AbsolutePage = intPage



intPageCount = rs.PageCount



If intPage > intPageCount Then



intPage = intPageCount



End If











If intPageCount > 1 Then



.Write ""











End If



End If







.Write ""



For i = 0 To intFieldCount - 1



.Write ""



Next



.Write ""







For i = 1 To intPageSize



If rs.EOF Then



Exit For



End If



.Write ""



For j = 0 To intFieldCount - 1



.Write ""



Next







.Write ""



rs.MoveNext



Next



.Write "

"



For i = 1 To intPageCount



If intPage = i Then



.Write "[" & i & "] "



Else



.Write "[" & i & "] "



End If



Next



.Write "
" & rs(i).Name & "
" & rs(j).Value & "

"



End With







rs.Close



Set rs = Nothing



con.Close



Set con = Nothing



End Function



[/code] 

相关阅读 Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么

文章评论
发表评论

热门文章 没有查询到任何记录。

最新文章 VB.NET 2005编写定时关 Jquery get/post下乱码解决方法 前台gbk gb如何使用数据绑定控件显示数据ASP脚本循环语句ASP怎么提速

人气排行 轻松解决"Server Application Error"和iis"一起学习DataGridView调整列宽用ASP随机生成文件名的函数Jquery get/post下乱码解决方法 前台gbk gbODBC Drivers错误80004005的解决办法返回UPDATE SQL语句所影响的行数的方法用Javascript隐藏超级链接的真实地址两个不同数据库表的分页显示解决方案