我不懂

dadaxiang 2002-04-03 11:22:12
为什么下面的代码不会其作用
运行结果一直是 系统发生0个错误
我对数据库链接怎么修改都是这样
<html>
<head>
<title></title>
</head>
<body>
<%
On Error Resume Next
const adCmdText = 1
const RecordsAffected = 0
Set Conn = Server.CreateObject("ADODB.Connection")

Conn.connection= "driver={sql server};server=ljf;UID=sa;PWD=as;Database=pubs"
conn.Open 
CommandText = "delete emp2 where job_id < 12"

Conn.Execute CommandText,RecordsAffected,adCmdText

Set myErrors = Conn.Errors
Response.write "系统发生" & myErrors.Count & "个错误<br>"

Response.write "<table border=3>"
For I=0 To MyErrors.Count -1
Response.write "<tr><td>Description属性</td>"
Response.write "<td>" & MyErrors(I).Description & "</td></tr>"
Response.write "<tr><td>Number属性</td>"
Response.write "<td>" & MyErrors(I).Number & "</td></tr>"
Response.write "<tr><td>Source属性</td>"
Response.write "<td>" & MyErrors(I).Source & "</td></tr>"
Response.write "<tr><td>NativeError属性</td>"
Response.write "<td>" & MyErrors(I).NativeError & "</td></tr>"
Response.write "<tr><td>SQLState属性</td>"
Response.write "<td>" & MyErrors(I).SQLState & "</td></tr>"
Response.write "<tr><td>HelpContext属性</td>"
Response.write "<td>" & MyErrors(I).HelpContext & "</td></tr>"
Response.write "<tr><td>HelpFile属性</td>"
Response.write "<td>" & MyErrors(I).HelpFile & "</td></tr>"
Next
Response.write "</table>"
Set Conn = nothing
%>
</body>
</html>
...全文
51 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
dadaxiang 2002-04-03
  • 打赏
  • 举报
回复
我是想让上面的程序出错一下,显示出来但是运行完后就是 :系统发生0个错误
forestli 2002-04-03
  • 打赏
  • 举报
回复
给你一个小例子。看看就会了!ASP连接数据库相关源代码参考
1. ASP连接Access数据库语句

Set Conn=Server.CreateObject("ADODB.Connection")
Connstr="DBQ="+server.mappath("aaa/bbspp1.mdb")+";DefaultDir=;DRIVER={Microsoft
AccessDriver(*.mdb)};DriverId=25;FIL=MSAccess;ImplicitCommitSync=Yes;MaxBufferSize=5
12;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UserCommitSync=Yes;"
Conn.Open connstr

其中Set Conn=Server.CreateObject("ADODB.Connection")为建立一个访问数据的对象
server.mappath( aaa/bbspp1.mdb)是告诉服务器access 数据库访问的路径

2. ASP连接Sqlserver数据库语句

Set conn = Server.CreateObject("ADODB.Connection")
conn.Open"driver={SQLServer};server=202.108.32.94;uid=wu77445;pwd=p780522;database=w
ww_panwei_com"
conn open                    
其中/Set conn = Server.CreateObject("ADODB.Connection")为设置一个数据库的连接对象
driver=()告诉连接的设备名是SQL-SERVER
server是连接的服务器的ip地址,Uid是指用户的用户名,pwd是指的用户的password,
database是用户数据库在服务器端的数据库的名称

28,406

社区成员

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

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