MSSQL 如果装在本地机器上,哪么,连接数据库的用户名、连接数据库的密码、数据库名这三个值要怎么写 15
2个回答
展开全部
方法一:
<%
dim conn
set conn=server.createobject("ADODB.connection")
conn.open "PROVIDER=SQLOLEDB;DATA SOURCE=(local);UID=用户名;PWD=密码;DATABASE=数据库"
Set conn = Server.CreateObject("ADODB.Connection")
DSNtemp="DRIVER={SQL Server};SERVER=(local);UID=用户名;PWD=密码;DATABASE=数据库"
conn.open DSNtemp
%>
方法二:
<%
option explicit
dim startime
dim conn
dim connstr
dim db,pass_word,User_ID,Data_Source
startime=timer()
db="数据库名称XK"
Pass_word="帐号密码123456"
User_ID="登陆帐号sa"
Data_Source="服务名称或者ip127.0.0.1"
Set conn = Server.CreateObject("ADODB.Connection")
connStr="Provider=SQLOLEDB.1;Password='"&pass_word&"';Persist Security Info=True;User ID='"&User_ID&"';Initial Catalog='"&db&"';Data Source='"&Data_Source&"'"
conn.Open connstr
function CloseDb
Conn.close
Set conn = Nothing
End Function
<%
dim conn
set conn=server.createobject("ADODB.connection")
conn.open "PROVIDER=SQLOLEDB;DATA SOURCE=(local);UID=用户名;PWD=密码;DATABASE=数据库"
Set conn = Server.CreateObject("ADODB.Connection")
DSNtemp="DRIVER={SQL Server};SERVER=(local);UID=用户名;PWD=密码;DATABASE=数据库"
conn.open DSNtemp
%>
方法二:
<%
option explicit
dim startime
dim conn
dim connstr
dim db,pass_word,User_ID,Data_Source
startime=timer()
db="数据库名称XK"
Pass_word="帐号密码123456"
User_ID="登陆帐号sa"
Data_Source="服务名称或者ip127.0.0.1"
Set conn = Server.CreateObject("ADODB.Connection")
connStr="Provider=SQLOLEDB.1;Password='"&pass_word&"';Persist Security Info=True;User ID='"&User_ID&"';Initial Catalog='"&db&"';Data Source='"&Data_Source&"'"
conn.Open connstr
function CloseDb
Conn.close
Set conn = Nothing
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询