做一个SQL查询显示页面,应该怎么做?

wlboy110 2005-06-10 02:45:08
想做一个测试页面,在输入栏写进去SQL语句,在页面内动态的查询出相应的记录并显示在页面内,能实现这样的dbgrid吗?
不知道数据列应该怎么去动态的确定?
...全文
103 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
dh20156 2005-06-10
  • 打赏
  • 举报
回复
参考:
<% dsn = "Driver=SQL Server;Server=localhost;UID=sa;PWD=??????;Database=Northwind"
Set conn = Server.CreateObject("Adodb.Connection")
conn.Open dsn %>

<% sql ="SELECT * FROM Shippers"
Set rs = Server.CreateObject("Adodb.Recordset")
rs.open sql,conn,1,1
If Not rs.eof then
fc = rs.fields.count-1
for i = 0 to fc
colname = colname + "<td>" + rs.fields(i).name + "</td>"
next
rc = rs.recordcount-1

Redim rsa(rc,fc)

dim n
n=0
do while not rs.eof
for m = 0 to fc
rsa(n,m) = rs.fields(m)
next
rs.MoveNext
n = n + 1
loop

end if
rs.close
Set rs = Nothing %>

<table border="1">
<tr><%=colname%></tr>
<%
for l = 0 to ubound(rsa)
response.write "<tr>"
for p = 0 to fc
response.write "<td>"
response.write rsa(l,p)
response.write "</td>"
next
response.write "</tr>" + chr(10)
next
%>
</table>

<% conn.close
Set conn = Nothing %>

其他模仿DATAGRID就自己去搞了!
comstep 2005-06-10
  • 打赏
  • 举报
回复
sql=request("sql")
set rs=server.cresteobject("adodb.recordset")
rs.open sql,conn,1,1


sql为文本筐输入的sql语句
kinogam 2005-06-10
  • 打赏
  • 举报
回复
ASP没有DATAGRID....只能通过提交,之后接受返回值....用request("xxxx")来接收....
之后赋值给一个变量
在通过这个变量来搜索............
比如
a=request("xxxx")
adors.open "select * from table where xxxx='"&a&"'"
这样来改变显示的值....
dh20156 2005-06-10
  • 打赏
  • 举报
回复
MARK一下先.

28,391

社区成员

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

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