asp 为什么不能调用数据库!
首页有个查询功能,点击确定后转到动作页面显示数据库里匹配的信息,可显示过程出了问题:哪位高人帮忙改下:
代码如下:数据库是customer,放在data文件夹下,要查询的数据(定单号,运单号..)在customer里面的表kehu里!
<%
dim dingdanhao,yundanhao
dingdanhao=request.form("dingdanhao")
dingdanhao=trim(dingdanhao)
yundanhao=request.form("yundanhao")
yundanhao=trim(yundanhao)
if dingdanhao="" then
response.write("<font color='red'>请输入您的定单号!</font>")
response.end()
end if
dingdanhao=replace(dingdanhao,"'","")
dingdanhao=replace(dingdanhao,"=","")
if yundanhao="" then
response.write("<font color='red'>请输入您的运单号!</font>")
response.end()
end if
yundanhao=replace(yundanhao,"'","")
yundanhao=replace(yundanhao,"=","")
dim connstr,conn,db
db="data/customer.mdb"
set conn=server.createobject("adodb.connection")
connstr="provider=microsoft.jet.oledb.4.0;data source="&server.mappath(db)
conn.open connstr
dim rs,sql
sql="select * from customer where ddh='"&dingdanhao&"'&ydh='"&yundanhao&"'
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if rs.eof then
response.write( 对不起,找不到该定单!)
response.write("<input type='button' value='返回' onclick='window.history.back();'>")
response.end()
end if
response.write("查询结果<hr size='1'>")
response.write("定单号:"&dingdanhao&"<br>")
response.write("运单号:"&yundanhao&"<br>")
response.write("发货日期:<font color='blue'>"&rs("stime")&"</font><br>")
response.write("预计收到日期:<font color='blue'>"&rs("atime")&"</font><br>")
response.write("货单金额:<font color='blue'>"&rs("pay")&"</font><br>")
response.write("<br>")
response.write("感谢您的查询!<input type='button' value='返回' onclick='window.history.back();'>")
rs.close
set rs=nothing
conn.close
set conn=nothing
end sub
%>