<%dimdbconstDatabaseType="ACCESS"db="data/cnhww.md..." />
您的位置首页百科知识

ASP连接SQL 2005 中的Conn.asp这个怎么修改?

ASP连接SQL 2005 中的Conn.asp这个怎么修改?

1.<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%><%dim dbconst DatabaseType="ACCESS" db="data/cnhww.mdb" On Error Resume Next dim ConnStr dim conn ConnStr = "正链Provider = Sqloledb; User ID = (MSSQL账号); Password = (MSSQL密码); Initial Catalog = (MSSQL数据库); Data Source = localhost(MSSQL地址,本地可以不用改);" ' ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db) Set conn = Server.CreateObject("ADODB.Connection") conn.Open connstr If Err Then err.Clear Set Conn = Nothing Response.Write "数据库连接出错,请检查Conn.asp文件中的数据库参数设置。" Response.End End Ifsub CloseConn() On Error Resume Next If IsObject(Conn) Then conn.close set conn=nothing end ifend sub%>2.第2个在admin文件里 <%dim dbconst DatabaseType="ACCESS" db="../data/cnhww.mdb" On Error Resume Next dim ConnStr dim conn 'ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db) ConnStr = "Provider = Sqloledb; User ID = (MSSQL账号); Password = (MSSQL密码); Initial Catalog = (冲祥MSSQL数据库); Data Source = localhost(MSSQL地址,本地可以不用改);" Set conn = Server.CreateObject("ADODB.Connection") conn.Open connstr If Err Then err.Clear Set Conn = Nothing Response.Write "散清搏数据库连接出错,请检查Conn.asp文件中的数据库参数设置。" Response.End End Ifsub CloseConn() On Error Resume Next If IsObject(Conn) Then conn.close set conn=nothing end ifend sub%>3.第3个在pay文件夹里<%db="../bbs/data/cnhww.mdb" Set conn = Server.CreateObject("ADODB.Connection")connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")conn.Open connstr%>