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

首頁 > 編程 > ASP > 正文

萬能數據庫連接程序

2024-05-04 10:59:12
字體:
來源:轉載
供稿:網友
簡介: 連接各種類型數據庫 及 對數據庫操作的函數

下面這部分程序可說是萬能的數據庫連接程序幾乎可以連接所有的MS數據庫,自己拿去研究吧(這個程序是“ASP網頁制作教程”這本書里面的——一本好書):
<%
'---------------------------------------------------
Function GetMdbConnection( FileName )
Dim Provider, DBPath

Provider = "Provider=Microsoft.Jet.OLEDB.4.0;"
DBPath = "Data Source=" & Server.MapPath(FileName)
Set GetMdbConnection = GetConnection( Provider & DBPath )
End Function

'---------------------------------------------------
Function GetSecuredMdbConnection( FileName, Password )
Dim Provider, DBPath

Provider = "Provider=Microsoft.Jet.OLEDB.4.0;"
DBPath = "Data Source=" & Server.MapPath(FileName)
Set GetSecuredMdbConnection = GetConnection( Provider & DBPath & ";Jet OLEDB:Database Password=" & Password ) End Function

'---------------------------------------------------
Function GetDbcConnection( FileName )
Dim Driver, SourceType, DBPath

Driver = "Driver={Microsoft Visual FoxPro Driver};"
SourceType = "SourceType=DBC;"
DBPath = "SourceDB=" & Server.MapPath( FileName )
Set GetDbcConnection = GetConnection( Driver & SourceType & DBPath )
End Function

'---------------------------------------------------
Function GetDbfConnection( Directory )
Dim Driver, SourceType, DBPath

Driver = "Driver={Microsoft Visual FoxPro Driver};"
SourceType = "SourceType=DBF;"
DBPath = "SourceDB=" & Server.MapPath( Directory )
Set GetDbfConnection = GetConnection( Driver & SourceType & DBPath )
End Function

'---------------------------------------------------
Function GetExcelConnection( FileName )
Dim Driver, DBPath

Driver = "Driver={Microsoft Excel Driver (*.xls)};"
DBPath = "DBQ=" & Server.MapPath( FileName )
Set GetExcelConnection = GetConnection( Driver & "ReadOnly=0;" & DBPath ) End Function

'---------------------------------------------------
Function GetTextConnection( Directory )
Dim Driver, DBPath

Driver = "Driver={Microsoft Text Driver (*.txt; *.csv)};"
DBPath = "DBQ=" & Server.MapPath( Directory )
Set GetTextConnection = GetConnection( Driver & DBPath )
End Function

'---------------------------------------------------
Function GetSQLServerConnection( Computer, UserID, Password, Db )
Dim Params, conn

Set GetSQLServerConnection = Nothing
Params = "Provider=SQLOLEDB.1"
Params = Params & ";Data Source=" & Computer
Params = Params & ";User ID=" & UserID
Params = Params & ";Password=" & Password
Params = Params & ";Initial Catalog=" & Db
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open Params
Set GetSQLServerConnection = conn
End Function

'---------------------------------------------------
Function GetMdbRecordset( FileName, Source )
Set GetMdbRecordset = GetMdbRs( FileName, Source, 2, "" )
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 得荣县| 紫金县| 萨迦县| 呼伦贝尔市| 枝江市| 阳山县| 临沂市| 吉安县| 民县| 北宁市| 永德县| 新昌县| 冕宁县| 保定市| 绍兴县| 济南市| 嵩明县| 合作市| 新宾| 介休市| 察隅县| 琼海市| 满洲里市| 阳东县| 庆安县| 寿阳县| 沈丘县| 五家渠市| 唐海县| 北碚区| 岳池县| 博乐市| 项城市| 舞钢市| 安丘市| 登封市| 永寿县| 本溪市| 白玉县| 辽源市| 清新县|