请教一个数据库查询语句!很简单的!

yezhutou 2003-08-22 01:10:20
我从我的ASP上得到webname和proname参数,现在要实现一个SQL查询,就是从库里找出满足站点名称=webname,工程名称=proname的数据记录,我我该怎么些这个查语句啊,我写的是
rs.open "select 监控点编号,监控点名称,监控点IP,站点名称,消息内容,注册 from CmpList where 站点名称=webname or 工程名称=proname","DSN=huanbao;"
实现不了,老是提示我有错。


...全文
27 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
ttt2 2003-08-22
  • 打赏
  • 举报
回复
left join
yezhutou 2003-08-22
  • 打赏
  • 举报
回复
我想改问一下,如果我是想实现多表的查询,比如到三个表中查询,而且查询条件也分别分布在三个表中,我该以什么格式进行书写啊?
yezhutou 2003-08-22
  • 打赏
  • 举报
回复
好了,我调通过了,我知道我的问题出在那里了,谢谢大家!
tongdou520 2003-08-22
  • 打赏
  • 举报
回复
你应该写是。select * from 数据库表 where webname="&站点名称&" and proname="&工程名称&"
Ianlan 2003-08-22
  • 打赏
  • 举报
回复
Set Conn=Server.createObject("Adodb.Connection")
strconn="DSN=huanbao;Uid=sa;Pwd=;" '这个连接要根据实际的用户来修改一下
Conn.Open strConn

set rs=server.createobject("adodb.recordset")
sql="select * from CmpList where 站点名称='"&webname&"' or 工程名称='"&proname&"'
rs.open sql,conn
yezhutou 2003-08-22
  • 打赏
  • 举报
回复
<html>
<head>
<title>查询结果</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#ffffdd">
<%
mwebname=request.form("webname")
mtime=request.form("time")
mproname=request.form("proname")
set cn=Server.CreateObject("ADODB.Connection")
Set cm=Server.CreateObject("ADODB.Command")
set rs=Server.CreateObject("ADODB.RecordSet")
rs.open "select 监控点编号,监控点名称,监控点IP,站点名称,消息内容,注册 from

CmpList","DSN=huanbao;"
%>
<table width="760" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="760" height="18" valign="left">
<p><font size="2">您输入的查询信息是 站点名称为:<% =mwebname %>;   时间为:

<% =mtime %>;   项目名称为:<% =mproname %>.</font></p>
</td>
<center>
</center>
</tr>
<tr>
<td valign="center" height="27" align="center"> <font color="#FF0000">您的查询结果如下

</font></td>
</tr>
</table>
<table width="758" border="1" >
<tr>
<center>
<td width="106" height="20" valign="center" align="center"><font color="#0000CC"

size="2.5">监控点编号</font></td>
<td width="106" valign="center" align="center"><font color="#0000CC" size="2.5">监控点名称

</font></td>
<td width="106" valign="center" align="center"><font color="#0000CC" size="2.5">监控点

IP</font></td>
<td width="126" valign="center" align="center"><font color="#0000CC" size="2.5">站点名称

</font></td>
<td width="188" valign="center" align="center"><font color="#0000CC" size="2.5">消息内容

</font></td>
<td width="86" valign="center" align="center"><font color="#0000CC" size="2.5">注册

</font></td>
</center>
</tr>
<% WHILE NOT rs.EOF %>
<tr>
<center>
<td width="106" height="20" valign="center" align="center"><font color="#0000CC" size="2.5"><%

=rs("监控点编号") %></font></td>
<td width="106" valign="center" align="center"><font color="#0000CC" size="2.5"><% =rs("监控点

名称")%></font></td>
<td width="106" valign="center" align="center"><font color="#0000CC" size="2.5"><% =rs("监控点

IP") %></font></td>
<td width="126" valign="center" align="center"><font color="#0000CC" size="2.5"><% =rs("站点名

称") %></font></td>
<td width="188" valign="center" align="center"><font color="#0000CC" size="2.5"><% =rs("消息内

容") %></font></td>
<td width="86" valign="center" align="center"><font color="#0000CC" size="2.5"><% =rs("注册")

%></font></td>
</center>
</tr>
<%
rs.MoveNext
WEND
%>
</table>
</body>
</html>
业余程序员 2003-08-22
  • 打赏
  • 举报
回复
rs.open "select 监控点编号,监控点名称,监控点IP,站点名称,消息内容,注册 from CmpList where 站点名称="&webname&" or 工程名称="&proname&""
xiejunhua 2003-08-22
  • 打赏
  • 举报
回复
贴出来一看不就明白了。
这样谁知哪错了。
业余程序员 2003-08-22
  • 打赏
  • 举报
回复
把那页面的程序粘出来不就行了这样我们怎么看得懂啊,
yezhutou 2003-08-22
  • 打赏
  • 举报
回复
还是不行啊,错误提示是:
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
/huanbao/result.asp, 第 14 行

什么意思啊?

cqfeng 2003-08-22
  • 打赏
  • 举报
回复
rs.open "select 监控点编号,监控点名称,监控点IP,站点名称,消息内容,注册 from CmpList where 站点名称='"&webname&"' or 工程名称='"&proname&"'"
jiejifeng 2003-08-22
  • 打赏
  • 举报
回复
sql="select * from table where 站点名称='"&webname&"' and 工程名称='"&proname&"'"

28,390

社区成员

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

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