asp连接sql数据库,access数据库字符串

来源:互联网 发布:js函数名声明变量声明 编辑:程序博客网 时间:2024/05/16 03:52

asp连接sqlserver数据库字符串代码:

 

<%

 

Set connsql = Server.CreateObject("ADODB.Connection")
strsql="Provider=SQLOLEDB.1;Password=y_ht1986;Persist Security Info=True;User ID=sa;Initial Catalog=newDdata9-1-4;Data Source=2FE7E52BA2E4457"
connsql.Open strsql


    If Err Then
        Err.Clear
        Set connconnsql = Nothing
        Response.Write "数据库连接出错,请检查Conn.asp文件中的数据库参数设置。2"
        Response.End
    End If
  


%>

asp连接access数据库字符串代码:

 

<%
'数据库连接程序
on error resume next
 connstr = "DBQ=" & server.mappath(Mydbpath & "db/shopwind.mdb") & ";DRIVER={Microsoft Access Driver (*.mdb)};"
 set conn = server.createobject("adodb.connection")
 conn.open connstr
if err.number<>0 then
 err.clear
 conn.close
 set conn = nothing
 response.write "对不起,您的数据库连接出错,请与管理员联系!"
 response.end
end if
%>