注册 登录
编程论坛 ASP技术论坛

数据库链接 出现乱码

金来 发布于 2008-01-31 12:13, 943 次点击
我有两个 asp页面  当第一个页面传递参数是数字时候 很容易就能读出来  但是  当传递参数是文字的时候 浏览器就显示 空白  估计是在值传递过程中发生乱码了   老师指点
<%
dim conn
set conn=server.createobject("ADODB.connection")
conn.open "PROVIDER=SQLOLEDB;DATA SOURCE=lll;UID=sa;PWD=000000;DATABASE=zhaopian"
%>
<%
dim bhx
bhx="老虎详细信息"
if (request ("id")<>"") then
bhx=request("id")
end if%>
<%
excu="select * from 招聘信息 where id='+bhx'"
Set rs =Server.CreateObject("ADODB.recordset")
rs.Open excu ,conn,1,1
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>动物信息查询</title>
</head>


<body>
<%if rs.EOF and rs.bof then
response.Write("暂时没有录入信息 ")
else
for i=1 to 10
if not rs.eof then  %>
<table width="589" height="59" border="2">
<tr>
    <td width="35"><%=rs("生长地")%></td>
</tr>

</table>   
<%  
rs.movenext
end if
next
end if %>
<%rs.close
set conn=nothing%>
</body>  这个是 chaxun.asp页面  下面这个是 提交表单页面


<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>查询</title>
</head>

<body>
<form id="form1" name="form1" method="get" action="chaxun.asp">
<p> 老虎名称:<input  name="id"  size="20" >
</p>
<P><input type="submit" value="提交" name="B1" > </P>
</form>
</body>
</html>

大家帮忙分析一下  我很无奈了已经   谢谢了

[[it] 本帖最后由 金来 于 2008-1-31 13:00 编辑 [/it]]
5 回复
#2
dhdhzzw2008-01-31 12:28
rs.Open excu ,conn,1,1
#3
金来2008-01-31 12:55
即使按楼上说的  也不行 不知道为什么    拜求赐教
#4
dhdhzzw2008-01-31 13:54
excu="select * from 招聘信息 where id='"&bhx&"'
#5
madpbpl2008-01-31 15:37
excu="select * from 招聘信息 where id="&bhx       '这里假设id的类型是int
excu="select * from 招聘信息 where id='"& bhx & "'"       '这里假设id的类型是text/varchar
id的数据类型是什么?

[[it] 本帖最后由 madpbpl 于 2008-1-31 15:41 编辑 [/it]]
#6
金来2008-02-18 15:11
问题解决了  谢谢大侠!!!~是自己写的代码的问题  参数变量形式

[[it] 本帖最后由 金来 于 2008-2-18 15:12 编辑 [/it]]
1