asp连接sql2000、sql2005、sql2008、access数据库连接字串

时间:2022-05-09 09:33:44

1、与sql2000连接字串:

Set Conn = Server.CreateObject("ADODB.Connection")

connstr="Provider=SqlOLEDB;Data Source=服务器IP(本地为local);initial catalog=数据库名;user ID=用户名;password=密码;"

Conn.Open connstr

 

 

2、与sql2005连接字串:

Set Conn = Server.CreateObject("ADODB.Connection")

connstr="Provider=SQLNCLI.1;Data Source=服务器IP(本地为local);initial catalog=数据库名;user ID=用户名;password=密码;"

Conn.Open connstr

 

2、与sql2008连接字串:

Set Conn = Server.CreateObject("ADODB.Connection")

connStr="Provider=SQLNCLI10;Persist Security Info=True;Data Source=127.0.0.1;uid=用户名;pwd=密码;database=数据库名;"'///SQL2008

Conn.Open connstr

 

 

3、与access连接字串:

Set Conn = Server.CreateObject("ADODB.Connection")

db="数据库路径"

connstr="Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&server.mappath(""&db&"")

Conn.Open connstr