不通过数据源完全控制MDB数据库

2016-01-29 20:11 7 1 收藏

不通过数据源完全控制MDB数据库,不通过数据源完全控制MDB数据库

【 tulaoshi.com - ASP 】

<%

' BEGIN USER CONSTANTS

' To just use a DSN, the format is shown on the next line:

'Const DSN_NAME = "DSN=ASP101email"

' Two other samples I used it with.  Left in as syntax examples for DSN-less connections

'Const DSN_NAME = "DBQ=C:InetPubwwwrootasp101samplesdatabase.mdb;Driver={Microsoft Access Driver (*.mdb)};DriverId=25"

'Const DSN_NAME = "DBQ=C:InetPubdatabasedonations.mdb;Driver={Microsoft Access Driver (*.mdb)};DriverId=25"

 

(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/asp/)

Dim DSN_NAME

DSN_NAME = "DBQ=" & Server.MapPath("db_dsn.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;"

Const DSN_USER = "username"

Const DSN_PASS = "password"

' Ok, I know these are poorly named constants, so sue me!

' This script can be used without actually setting up a DSN, so

' DSN_NAME as well as the other two constants should really be named

' something more generic like CONNECTION_STRING, CONNECTION_USER, and

' CONNECTION_PASS, but I did it this way without really thinking about

' it and I'm too lazy to change it now.  If it bothers you, you do it!

' END USER CONSTANTS

 

(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/asp/)

' BEGIN SUBS & FUNCTIONS SECTION

Sub OpenConnection

Set objDC = Server.CreateObject("ADODB.Connection")

objDC.ConnectionTimeout = 15

objDC.CommandTimeout = 30

objDC.Open DSN_NAME, DSN_USER, DSN_PASS

End Sub

 

(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/asp/)

Sub OpenRecordset(sType)

Dim sSqlString ' as String - building area for SQL query

Dim sCritOperator ' as String - basically "=" or "LIKE"

Dim sCritDelimiter ' as String - parameter delimiter "", "'", or "#"

 

(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/asp/)

Set objRS = Server.CreateObject("ADODB.Recordset")

Select Case sType

Case "ListTables" ' Open RS of the Tables in the DB

Set objRS = objDC.OpenSchema(adSchemaTables)

Case "ViewTable"  ' Open the Selected Table

Set objRS = Server.CreateObject("ADODB.Recordset")

objRS.Open "[" & sTableName & "]", objDC, adOpenForwardOnly, adLockReadOnly

Case "DrillDown"  ' Open the Recordset built by the selected options

Set objRS = Server.CreateObject("ADODB.Recordset")

 

(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/asp/)

' Build Our SQL Statement

sSqlString = "SELECT * FROM [" & sTableName & "]"

 

(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/asp/)

' If we're limiting records returned - insert the WHERE Clause into the SQL

If sCritField < "" Then

' Figure out if we're dealinh with Numeric, Date, or String Values

Select Case iCritDataType

Case adSmallInt, adInteger, adSingle, adDouble, adDecimal, adTinyInt, adUnsignedTinyInt, adUnsignedSmallInt, adUnsignedInt, adBigInt, adUnsignedBigInt, adBinary, adNumeric, adVarBinary, adLongVarBinary, adCurrency, adBoolean

sCritOperator = "="

sCritDelimiter = ""

Case adDate, adDBDate, adDBTime, adDBTimeStamp

sCritOperator = "="

sCritDelimiter = "#"

Case adBSTR, adChar, adWChar, adVarChar, adLongVarChar, adVarWChar, adLongVarWChar

sCritOperator = "LIKE"

sCritDelimiter = "'"

End Select

(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/asp/)

sSqlString = sSqlString & " WHERE [" & sCritField & "] " & sCritOperator & " " & sCritDelimiter & sCritValue & sCritDelimiter

End If

 

(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/asp/)

' If we're sorting - insert the ORDER BY clause

If sSortOrder < "none" Then

sSqlString = sSqlString & " ORDER BY [" & sSortField & "] " & sSortOrder

End If

 

(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/asp/)

sSqlString = sSqlString & ";"

 

(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/asp/)

' Open the actual Recordset using a Forward Only Cursor in Read Only Mode

objRS.Open sSqlString, objDC, adOpenForwardOnly, adLockReadOnly

End Select

(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/asp/)

End Sub

 

(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/asp/)

Sub CloseRecordset

objRS.Close

Set objRS = Nothing

End Sub

 

(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/asp/)

Sub CloseConnection

objDC.Close

Set objDC = Nothing

End Sub

 

(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/asp/)

Sub WriteTitle(sTitle)

Response

来源:http://www.tulaoshi.com/n/20160129/1510836.html

延伸阅读
标签: Web开发
前言:好长时间了,从刚开始的站点管理器到现在流行的几款asp后门,相信大多网管都能说出这些经典webshell的名字,如海洋、老兵、蓝屏等,也相信大多数的网管学会了关键字的搜索方法来搜索这些木马,当然现在的时间如果再象隐藏后门就要讲些技巧啦,俗话说的好“佛高一尺,我高一丈”。 我不否认n早前的那个把asp木马写到图片文件中不...
    很多朋友只用了Oracle的删除,但很多情况下,他会发现重新安装时,点了下一步安装界面就消失了,往往无奈下只好重装系统,其实只是你数据库没删干净,删干净就不会出现这种情况了。 实现方法: 1、开始-设置-控制面板-管理工具-服务停止所有Oracle服务。 2、开始-程序-Oracle - OraHome81-Oracle Installat...
在Oracle数据库运行期间,DBA应该对数据库的运行日志及表空间的使用情况进行监控,及早发现数据库中存在的问题。 一、Oracle警告日志文件监控 Oracle在运行过程中,会在警告日志文件(alert_SID.log)中记录数据库的一些运行情况: ●数据库的启动、关闭,启动时的非缺省参数; ●数据库的重做日志切换情况,记录每次切换的时间,及如果...
注释:本文中的信息仅适用于 Microsoft Access 数据库 (.mdb)。 当有其他用户正打开 Access 数据库时,用户不能将设计更改保存到 Microsoft Access 数据库中。确保更改保存的唯一途径是以独占 模式打开 Access 数据库。 通常,当试图对数据库对象(不包括表和查询)或共享模式下的某个项目进行设计更改时,如果您当时是 Access 数据库的唯...
Visual Basic对Access数据库的集成非常紧密,通常由以下几个部分组成。 引用DAO类型库 1、从“工程”菜单中选择“引用”菜单项; 2、在可引用列表框中选择“Microsoft DAO 3.51 Object Library”项。 3、最后“确定”即可 设置DAO数据类型变量 DAO数据类型变量共分成两种: 1、Database变量 ...

经验教程

510

收藏

32
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部