运用 SQL 语句查询的 ASP 程序

来源:百度知道 编辑:UC知道 时间:2024/06/20 14:13:43
< %
sub query2table(inputquery)
set conntemp=server.createobject("adodb.connection")
conntemp.open "DSN=Student;uid=student;pwd=aspmagic"
set rstemp=conntemp.execute(inputquery)
howmanyfields=rstemp.fields.count -1
\' 统计数据库中的列数
%>
< table border=1>< tr>
< %
for i=0 to howmanyfields
%>
< td>< b>< %=rstemp(i).name%>< /B>< /TD>
< % next %>
< /tr>
< %
do while not rstemp.eof
%>
< tr>
< % for i = 0 to howmanyfields
thisvalue=rstemp(i)
If isnull(thisvalue) then
thisvalue="?
\' 如果字段为空,则将变量 thisvalue 的值定义为一个空格
end if%>
< td valign=top>< %=thisvalue%>< /td>
< % next %>
< /tr>
< %rstemp.movenext
loop%>
< /table>
< %
rstemp.close
set rstemp=nothing
conntemp.close

这是定义一个名为query2table过程带有一个值,inputquery值是一条SQL语句
howmanyfields=rstemp.fields.count -1
这句的话应该是CONN的一个属性,你可以去查下看看,这我很少接触所以不太清楚
前面的弄明白了我想后面的就应该好理解了,
有什么问题可以发消息给我
希望我能帮到你

< %
sub query2table(inputquery)
set conntemp=server.createobject("adodb.connection")
conntemp.open "DSN=Student;uid=student;pwd=aspmagic"
set rstemp=conntemp.execute(inputquery)
howmanyfields=rstemp.fields.count -1
\' 统计数据库中的列数
%>
< table border=1>< tr> 设置表格边框为1
< %
for i=0 to howmanyfields 设置循环次数
%>
< td>< b>< %=rstemp(i).name%>< /B>< /TD>
< % next %>
< /tr>
< %
do while not rstemp.eof
%>
< tr>
< % for i = 0 to howmanyfields
thisvalue=rstemp(i)
If isnull(thisvalue) then
thisvalue="?
\' 如果字段为空,则将变量 thisvalue 的值定义为一个空格
end if%>
< td valign=top