加入收藏 | 设为首页 | 会员中心 | 我要投稿 衡阳站长网 (https://www.0734zz.cn/)- 数据集成、设备管理、备份、数据加密、智能搜索!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

数据库连接大全

发布时间:2020-12-26 07:13:13 所属栏目:Asp教程 来源:网络整理
导读:无意中在公司的电脑里发现前人留下的一个db.fun的文件,打开一看原来是众多连接数据库的函数。也许用得着,收录一下。 % '--------------------------------------------------- Function GetMdbConnection( FileName ) ?? Dim Provider,DBPath ?? Provider

?? On Error Resume Next
?? Set GetMdbRs = Nothing
?? If Len(Password) = 0 Then
?????? Set conn = GetMdbConnection( FileName )
?? Else
?????? Set conn = GetSecuredMdbConnection( FileName,Password )
?? End If
?? If conn Is Nothing Then Exit Function

?? Set rs = Server.CreateObject("ADODB.Recordset")
?? If Err.Number <> 0 Then Exit Function

?? rs.Open source,2
?? If Err.Number <> 0 Then Exit Function
?? Set GetMdbRs = rs
End Function

'---------------------------------------------------
Function GetOtherRs( DataType,Path,Cursor )
?? Dim conn,rs
?? On Error Resume Next
?? Set GetOtherRs = Nothing

?? Select Case DataType
????? Case "Dbf"
???????? Set conn = GetDbfConnection( Path )
????? Case "Dbc"
???????? Set conn = GetDbcConnection( Path )
????? Case "Excel"
???????? Set conn = GetExcelConnection( Path )
????? Case "Text"
???????? Set conn = GetTextConnection( Path )
?? End Select
?? If conn Is Nothing Then Exit Function

?? Set rs = Server.CreateObject("ADODB.Recordset")
?? If Err.Number <> 0 Then Exit Function

?? rs.Open SQL,2
?? If Err.Number <> 0 Then Exit Function
?? Set GetOtherRs = rs
End Function

'---------------------------------------------------
Function GetSQLServerRs( Computer,Db,source,rs

?? On Error Resume Next
?? Set GetSQLServerRs = Nothing
?? Set conn = GetSQLServerConnection( Computer,Db )
?? If conn Is Nothing Then Exit Function
??
?? Set rs = Server.CreateObject("ADODB.Recordset")
?? If Err.Number <> 0 Then Exit Function
??
?? rs.Open source,2
?? If Err.Number <> 0 Then Exit Function
??
?? Set GetSQLServerRs = rs
End Function
%>

(编辑:衡阳站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

推荐文章
    热点阅读