ASP数据库自动转换问题

来源:百度知道 编辑:UC知道 时间:2024/05/28 09:26:33
<%
dim conn
dim connstr

'================================================================================================================
'IsSqlDataBase = 0 为ACC数据库 IsSqlDataBase = 1 为SQL数据库
Const IsSqlDataBase = 0
'================================================================================================================
MyDbPath = ""
'================================================================================================================
If IsSqlDataBase = 1 Then
'================================================================================================================
Const SqlDatabaseName = "数据库名"
Const SqlPassword = "密码"
Const SqlUsername = "用户名"
Const SqlLocalName = "服务器IP"
Else
db="ACC数据库路径"

end if
set conn = Server.CreateObject("ADODB.Connection")
If IsSqlDataBas

ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(MyDbPath & db)
Data Source = " & Server.MapPath(MyDbPath & db) 有问题
取得了路径但是你的acc数据库呢?

on error resume next
'此处sql server连接
if err<>0 then
'此处access连接
endif

on error resume next'跳过错误继续执行下面语句

连接SQLSERVER
if err <> "" then
连接ACCESS
end if
连接对象一样就行了