asp连接MSSQLServer数据库有问题:

dmss 2003-10-15 10:42:16
编写的代码如下:
<%
Set conn = Server.CreateObject("ADODB.Connection")
connstr="DRIVER={SQL Server};SERVER=localhost;UID=sa;PWD='';DATABASE=My"
conn.open connstr
%>

运行结果如下:

错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E4D)
/test/conn.asp, 第 4 行
浏览器类型:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.2914; COM+ 1.0.2204; .NET CLR 1.0.3705)
页:
GET /test/store.asp
...全文
24 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
qong 2003-10-15
  • 打赏
  • 举报
回复
<%set conn=server.CreateObject("ADODB.connection")
StrCnn ="Provider=SQLOLEDB;User ID=sa;Password=;database=my;Data Source=(local)"
conn.Mode=admodereadwrite
conn.ConnectionString=strcnn
conn.Open
%>
试一下。。。
bluemoon0001 2003-10-15
  • 打赏
  • 举报
回复
呵呵,你写的我不懂,我给你一段通用代码:
<% dim conn,connstr,strDatabaseType
strDatabaseType="aceess"
'strDatabaseType="sqlserver"
if strDatabaseType="aceess" then
connstr="provider=microsoft.jet.oledb.4.0;data source=" & server.mapPath("db/db2.mdb")
else

dim dbuid,dbpwd,dbname,dbip
dbuid="sa" '数据库登陆名
dbpwd="000000" '数据库密码
dbname="sfsfs" '数据库名
dbip="hostname" '数据库所在的机器名称,也可以是本机的IP
connstr="PROVIDER=SQLOLEDB;DATA SOURCE="&dbip&";UID="&dbuid&";PWD="&dbpwd&";DATABASE="&dbname
end if

set conn=Server.CreateObject("adodb.Connection")
conn.open connstr
%>
BingGroup 2003-10-15
  • 打赏
  • 举报
回复
在VB 中用ADODB测试以下连接字符串
lihua9666 2003-10-15
  • 打赏
  • 举报
回复
配置odbc的话用吧
connstr="DSN=my;UID=sa;PWD="
lihua9666 2003-10-15
  • 打赏
  • 举报
回复
配置odbc的话用吧
connstr="DSN=my;UID=sa;PWD="
shijian58 2003-10-15
  • 打赏
  • 举报
回复
这个我正在用,应该可以:
<%
dim strconn,conn
strconn = "Driver={SQL Server};Description=sqldemo;SERVER=localhost;UID=sa;PWD=password;DATABASE=BookShoping;"
set conn = server.createobject("adodb.connection")
conn.open strconn

%>
laibagefei 2003-10-15
  • 打赏
  • 举报
回复
这样应该可以了

<%
Set conn = Server.CreateObject("ADODB.Connection")
connstr="DRIVER={SQL Server};SERVER=localhost;UID=sa;PWD=;DATABASE=My"
conn.open connstr
%>

看如此可否:

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧