国产探花免费观看_亚洲丰满少妇自慰呻吟_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, "" )
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 额济纳旗| 太和县| 兴业县| 京山县| 若尔盖县| 天津市| 台中市| 大洼县| 德格县| 南部县| 都匀市| 凌云县| 沁水县| 巴马| 贡觉县| 维西| 葵青区| 石楼县| 黑龙江省| 宁德市| 彭阳县| 尉氏县| 富平县| 壤塘县| 大新县| 河南省| 新乡市| 常山县| 修武县| 抚顺县| 延安市| 扶余县| 通江县| 甘德县| 南木林县| 望奎县| 隆安县| 修武县| 静海县| 商南县| 商丘市|