求助,代码修改.
<%
dim conn
dim connstr
on error resume next
sub TLconnstr
connstr= "DBQ= "+server.mappath( "1.mdb ")+ ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)}; "
set conn=server.createobject( "ADODB.CONNECTION ")
conn.open connstr
end sub
sub TLconnstr1
connstr= "DBQ= "+server.mappath( "db1.mdb ")+ ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)}; "
set conn=server.createobject( "ADODB.CONNECTION ")
conn.open connstr
end sub
%> 现将1.mdb改成MSSQL数据库,以上代码如何修改?
------解决方案-------------------- <%
dim conn
set conn=server.createobject( "ADODB.connection ")
conn.open "PROVIDER=SQLOLEDB;DATA SOURCE=SQL服务器名称或IP地址;UID=sa;PWD=数据库密码;DATABASE=数据库名称
%>
按照这个方案修改
------解决方案-------------------- <%
dim conn
dim connstr
on error resume next
sub TLconnstr
connstr= "Driver={sql server};server=服务器或IP;database=数据库名;uid=sa用户;pwd=密码; "
set conn=server.createobject( "ADODB.CONNECTION ")
conn.open connstr
end sub
sub TLconnstr1
connstr= "Driver={sql server};server=服务器或IP;database=数据库名;uid=sa用户;pwd=密码; "
set conn=server.createobject( "ADODB.CONNECTION ")
conn.open connstr
end sub
%>
------解决方案--------------------sub TLconnstr
dim Sql_Server,Sql_User,Sql_Pass,Sql_Data
Sql_Server = "localhost " '数据库服务器地址
Sql_User = "sa " '数据库登录名
Sql_Pass = "**** " '数据库密码
Sql_Data = "*** " '数据库名
dim conn,connstr
connstr = "PROVIDER=SQLOLEDB;DATA SOURCE= "&Sql_Server& ";UID= "&Sql_User& ";PWD= "&Sql_Pass& ";DATABASE= "&Sql_Data
set conn = server.createobject( "ADODB.connection ") '创建数据库连接对象
conn.open connstr
end sub
------解决方案--------------------学习
------解决方案--------------------http://community.csdn.net/IndexPage/SmartQuestion.aspx#bespecific
------解决方案--------------------楼上回答正确.