数据库连接代码(CONN.ASP文件)

2012 年 12 月 8 日5520

数据库连接代码(CONN.ASP文件)
供稿:润之康 时间:2006-5-14 20:15:18

ACCESS数据库接接代码:

dim db,Conn,ConnStr

db="您的ACCESS数据库路径"
set conn=Server.CreateObject("ADODB.Connection")
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(db)
conn.open ConnStr

MS SQL Server数据库接接代码:

dim SqlDatabaseName,SqlPassword,SqlUsername,SqlLocalName,Conn,ConnStr

SqlDatabaseName="SQL数据库名称"
SqlPassword="SQL数据库登密码"
SqlUsername="SQL数据库登陆用户名"
SqlLocalName="SQL服务器IP地址"

set conn=Server.CreateObject("ADODB.Connection")
ConnStr = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
conn.open ConnStr

或者ConnStr也可以用:ConnStr = "driver={SQL SERVER};database=" & SqlDatabaseName & "; uid=" & SqlUsername & "; pwd=" & SqlPassword & "; server=" & SqlLocalName & ""

快网保留以上说明的最终解释权

0 0