ASP与SQL server2000数据库连接出现问题?
我的是ASP跟SQL server2000数据库连接的,需要更改为什么呢,我自己弄总是显示“数据库连接出错,请检查连接字串” 我的SQL SERVER数据库为“ABC_Date.mdf” 路径为Data/ABC_Date.mdf 请高手指导下 谢谢!
我的程序如下:
Dim Db,conn,openchick
Dim SqlNowString,team,Cache
dim Startime,MyDbPath,SqlQueryNum
Startime=timer()
SqlQueryNum = 0
openchick = 0 '后台的验证码开关,0为开.1为关.
Const ManagePath="Manage/" '自设置管理后台的文件夹路径
Const IsSqlDataBase=1 '定义数据库类别,0为Access数据库,1为SQL数据库
Const IsDeBug = 0 '定义运行模式,测试为1,正常运行为0,不输出错误信息有利于安全
If IsSqlDataBase = 1 Then 'sql数据库连接参数
Const SqlDatabaseName = "ABC_Data" '数据库名(SqlDatabaseName)
Const SqlPassword = "saa" '用户密码(SqlPassword)
Const SqlUsername = "saa" '用户名(SqlUsername)
Const SqlLocalName = "(local)" '连接名(SqlLocalName)(本地用local,外地用IP)
SqlNowString = "GetDate()"
Else
Db = "Data/ABC_Data.MDF"
SqlNowString = "Now()"
End If
Sub ConnectionDatabase
Dim ConnStr
If IsSqlDataBase = 1 Then
ConnStr = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
Else
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(MyDbPath & db)
End If
On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnStr
If Err Then
err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请检查连接字串。"
Response.End
End If
End Sub
Sub Plus_ConnectionDatabase
Dim ConnStr
If IsSqlDataBase = 1 Then
'sql数据库连接参数:数据库名、用户密码、用户名、连接名(本地用local,外地用IP)
Dim SqlDatabaseName,SqlPassword,SqlUsername,SqlLocalName
SqlDatabaseName = "ABC_Data"
SqlPassword = "saa"
SqlUsername = "saa"
SqlLocalName = "(local)"
ConnStr = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
Else
Dim Db
'使用前请修改本处数据库地址和数据库名称,如将Plus.mdb修改为#%$Plus_TT.mdb
Db = MyDbPath & "Data/ABC_Data.MDF"
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(db)
End If
On Error Resume Next
Set Plus_Conn = Server.CreateObject("ADODB.Connection")
Plus_Conn.open ConnStr
If Err Then
err.Clear
Set Plus_Conn = Nothing
Response.Write "插件数据库连接出错,请检查连接字串。"
Response.End
End If
End Sub