一聚教程网:一个值得你收藏的教程网站

热门教程

万能的数据库连接程序

时间:2022-06-30 10:26:44 编辑:袖梨 来源:一聚教程网

我从来就不用DNS连接,我觉得那个很不方便,下面这部分程序可说是万能的数据库连接程序几乎可以连接所有的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 )

热门栏目