求代码!

sound2003 2003-10-15 05:21:34
我刚学做网页,现在有报价系统放在网页上,我已在Access里建一个数据库"ncc.mdb"(放在"data"目录下,里放着各种表,
如"food"(食品),"water"(饮料)两张表,每张表有"name"(名称),"say"(说明),"cost"(价格)等字段.在网页上左边做个链接,如点击"食品"就在网页的右边建立一张表格,将所有记录都显示出来,如何用vbscript实现.
...全文
98 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
blueice2002 2003-10-16
  • 打赏
  • 举报
回复
<%
if not rs.eof then
i=0
do while not rs.eof
%>
<tr class=main1>
<td width="38" height="23"><a href="t_File_info.asp?file_id=<%=rs("FileID")%>" target="_blank"><%=rs("FileID")%></a></td>
<td width="106" height="23"><%=rs("FileName")%> </td>
<td width="62" height="23"><%= rs("FileFormat") %> </td>
<td width="39" height="23"><%if rs("FileType")=0 then
response.write "文件"
else response.write "目录"
end if %> </td>
<td width="150" height="23"><%= rs("InsertDate") %> </td>
<td width="265" height="23">
<p align="center"><font color="#000080"><span lang="zh-cn">存储位置 
<a target="_blank" href="t_File_Program.asp?file_id=<%=rs("FileID")%>"><font color="#000080">节目信息</font></a>  修改  删除
</span></font></td>
</tr>
<%
i=i+1
if i >= MaxPerpage then exit do
rs.movenext
loop
end if
%>

</table>
</TD></TR>
<TR bgColor=#e1f0ff>
<TD class=main1 width="667" height="27" bordercolordark="#808000" bgcolor="#F3F3F3">

</TD></TR>
<TR bgColor=#e1f0ff>
<TD class=main1 width="667" height="1" bgcolor="#F8E8A0"" background="images/bg.gif"></TD></TR></TBODY></TABLE>
<%
End sub
rs.close
%> </center>
</div>
<div align="center" style="width: 696; height: 3">
<center>
</form>
<%
'显示翻页的子程序
sub showpages()%> <table bgColor="#E4DEC70" border="0" cellPadding="0" cellSpacing="0" width="100%" >
<tr><td >
<%
response.write "<form method=Post action='t_File_list.asp'>"
%>

<table bgColor="#1f60a0" border="0" cellPadding="0" cellSpacing="0" width="100%" >
<tr>
<td bgcolor="#e1foff" class=main1>
<font color="#000000">
<p align="left">
<%
Response.write "<font color='#000000'>分页-</font>"
If currentpage > 1 Then
response.write "<a href='t_File_list.asp?&page="+cstr(1)+"'><font color='#000000'>首页</font></a><font color='#000000'><b>-</b></font>"
Response.write "<a href='t_File_list.asp?page="+Cstr(currentpage-1)+"'><font color='#000000'>前页</font></a><font color='#000000'><b>-</b></font>"
Else
Response.write "<font color='#000000'>首页-</font>"
Response.write "<font color='#000000'>前页-</font>"
End if

If currentpage < Rs.PageCount Then
Response.write "<a href='t_File_list.asp?page="+Cstr(currentPage+1)+"'><font color='#000000'>后页</font></a><font color='#000000'><b>-</b></font>"
Response.write "<a href='t_File_list.asp?page="+Cstr(Rs.PageCount)+"'><font color='#000000'>尾页</font></a>  "
Else
Response.write "<font color='#000000'>后页-</font>"
Response.write "<font color='#000000'>尾页</font>  "
End if
Response.write "<font color='#000000'>页次:</font>" & "<font color=#FF0000>" & Cstr(CurrentPage) & "</font>" & "<font color='#000000'>/" & Cstr(rs.pagecount) & "</font> "
Response.write "<font color=#ff0000>" & Cstr(MaxPerPage) & "</font>" & "<font color='#000000'>条记录/页 " & "共</font>" & "<font color=#FF0000>" & Cstr(Rs.RecordCount) & "</font>" & "<font color='#000000'>条记录</font>  "

response.write "</td><td align='right'>"
response.write "<font color='#ffffff' class=main1 >转到:</font><input type='text' name='page' size=4 maxlength=4 class=smallInput value="¤tpage&"> "
response.write "<input class=buttonface type='submit' value='Go' name='cndok' style='background-color: #D4D0C8' ></span>  "
%>

</font>
</td>
</tr>
</table>
</center>
</td></tr>
</table>

</form>
<%end sub%>

</div>

</center>
</body>
</html>
blueice2002 2003-10-16
  • 打赏
  • 举报
回复
分页程序
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
'*****************************************
'** 工 程:流媒体发布系统
'** 功 能:文件管理显示列表
'** 文 件:t_File_list.asp
'** 作 者:blueice,blueiceblue@etang.com
'** 时 间:2003-10-08
'** 输 入:
'** 输 出:
'** 最后修改时间:
'*****************************************
%>
<!--#include file="../Connections/Conn_media.asp" -->
<%
bo_Class=request("Class")
bo_name=request("name")
sql="ORDER BY FileID DESC"
if bo_class="按文件ID" then
'sql="and FileID like '%" request("name")& sql
sql="and FileID like '%"& request("name") &"%'"&sql
end if
if bo_class="按文件名" then
sql="and FileName like '%"& request("name") &"%'"&sql
end if
%>
<head>
<title>文件管理显示列表</title>

<STYLE type=text/css>.main {
FONT-SIZE: 12px
}
.main1 {
FONT-SIZE: 9pt
}
.main2 {
FONT-SIZE: 16px
}
.main3 {
FONT-SIZE: 7px
}
.main4 {
FONT-SIZE: 10px
}
A:link {
COLOR: #000000; TEXT-DECORATION: none
}
A:visited {
COLOR: #ff0000; TEXT-DECORATION: none
}
A:active {
COLOR: #ff0000; TEXT-DECORATION: none
}
A:hover {
COLOR: #ff0000; TEXT-DECORATION: underline
}
</STYLE>
</head>
<body text="#000000" topmargin="0" leftmargin="0"><center>
<table width="676">
<tr>
<td width="670">
<b><font size="2">文件管理 </font></b>
</td>
</tr>
</table>

<div align="center" style="width: 677; height: 102">

<center>
<%
dim rs,sqltext
set rs=server.createobject("adodb.recordset")
sqltext="select * from t_File where FileID>0 and stopFlag='1' "&sql
rs.open sqltext,MM_Conn_media_STRING ,1,1

dim MaxPerPage
MaxPerPage=20

'假如没有数据时
If rs.eof and rs.bof then
call showpages
response.write "<p align='center'><font color='#ff0000'>还没任何文件信息</font></p>"
response.end
End if

'取得页数,并判断用户输入的是否数字类型的数据,如不是将以第一页显示
dim text,checkpage
text="0123456789"
Rs.PageSize=MaxPerPage
for i=1 to len(request("page"))
checkpage=instr(1,text,mid(request("page"),i,1))
if checkpage=0 then
exit for
end if
next

If checkpage<>0 then
If NOT IsEmpty(request("page")) Then
CurrentPage=Cint(request("page"))
If CurrentPage < 1 Then CurrentPage = 1
If CurrentPage > Rs.PageCount Then CurrentPage = Rs.PageCount
Else
CurrentPage= 1
End If
If not Rs.eof Then Rs.AbsolutePage = CurrentPage end if
Else
CurrentPage=1
End if

call showpages
call list

'If Rs.recordcount > MaxPerPage then
call showpages
'end if

'显示帖子的子程序
Sub list()%> </center>
<form method='POST' action='t_File_list.asp'>
<center>
<TABLE cellSpacing=1 cellPadding=4 width=677 bgColor=#416327 height="96">
<TBODY>
<TR vAlign=top bgColor=#e1f0ff>
<TD class=main1 height="4" width="667" bgcolor="#E4DEC7"></TD></TR>
<TR vAlign=top bgColor=#e1f0ff>
<TD class=main1 height="18" bgcolor="#F3F3F3" width="667">
<span lang="zh-cn">文件</span>信息检索: <select name='Class' size='1' tabindex='0' style="font-size: 9pt">
<option value='按文件ID'>按文件ID</option>
<option value="按文件名">按文件名</option>
</select>
<input type='text' name='Name' size='20' onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''" style="font-family: 新细明体, 宋体, Arial; font-size: 9pt; height:18px;background-color:#f3f3f3;border:1 solid black">
<input type='submit' value='查询' name='Submit' style="font-family: 新细明体, 宋体, Arial; font-size: 9pt; height:20px;background-color:#D4D0C8;" onMouseOver ="this.style.backgroundColor='#FFC864'" onMouseOut ="this.style.backgroundColor='#D4D0C8'">
<span lang="zh-cn">                                        
<font color="#000080"><a target="_self" href="t_File_add.asp">
<font color="#000080">新增文件</font></a></font></span></TD></TR>
<TR vAlign=top bgColor=#e1f0ff>
<TD class=main1 height="1" width="667">
<table border="1" cellpadding="0" cellspacing="0" width="667" bordercolorlight="#416327" bordercolordark="#e1f0ff" height="37" style="border-collapse: collapse" bordercolor="#111111">
<tr class=main1>
<td width="38" height="13"> <p align="center"><span lang="zh-cn">文件</span>ID</td>
<td width="106" height="13"> <p align="center"><span lang="zh-cn">文件名</span></td>
<td width="62" height="13">
<p align="center"><span lang="zh-cn">文件格式</span></td>
<td width="39" height="13">
<p align="center"><span lang="zh-cn">类型</span></td>
<td width="150" height="13"> <p align="center"><span lang="zh-cn">插入时间</span></td>
<td width="265" height="13"> </td>
</tr>
blueice2002 2003-10-16
  • 打赏
  • 举报
回复
asp与sql server 数据库的连接
<%
'连接数据库————————————————————————————
set conn=server.createobject("adodb.connection")
Connstr="Provider=SQLOLEDB;Data Source=127.0.0.1;UID=sa;PWD=sa;DataBase=web"
'打开数据库——————————————————————————————————
conn.open connstr
'写数据查询语句————————————————————————
set rs=conn.execute("select * from asp where id>2")
'输出查询结果——————————————————————————
do until rs.eof
response.write rs("id")&"<br>"
response.write rs("name")&"<br>"
rs.movenext
loop
%>
************************************
asp与access 数据库的连接
********************************
<% dim conn
dim connstr
on error resume next
connstr="DBQ="+server.mappath("login.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
if err then
err.clear
else
conn.open connstr
if err then
err.clear
end if
end if
set rs=conn.execute("select * from login_info where id>1")
do until rs.eof
response.write rs("id")&"<br>"
response.write rs("username")&"<br>"
response.write rs("password")&"<br>"
rs.Movenext
loop %>

*****************************************************
*****************************************************
<!--#include file="conn.asp"-->
<%
set rs=conn.execute("select * from login_info where id>2")
'set rs=server.createobject("adodb.recordset")
'sql="select * from login_info where id > ='1' "
'rs.open sql,conn,1,1
do until rs.eof
response.write rs("id")&"<br>"
response.write rs("username")&"<br>"
response.write rs("password")&"<br>"
rs.Movenext
loop
%>

**********************************************************
***********************************************************





SELECT语法:(基本)



*************************************************************
**********************************************************
SELECT [DISTINCT]
(column [{, column } ] )| *
FROM table [ { , table} ]
[ORDER BY column [ASC] | [DESC
[{ , column [ASC] | [DESC } ] ]
WHERE predicate [ { logical-connector predicate } ];
------------------------------------------------------

INSERT语法:

INSERT INTO table
[(column { ,column})]
VALUES
(columnvalue [{,columnvalue}]);
------------------------------------------------------

UPDATE语法:

UPDATE table
SET column = value [{, column = value}]
[ WHERE predicate [ { logical-connector predicate}]];
------------------------------------------------------

DELETE语法:

DELETE FROM table
[WHERE predicate [ { logical-connector predicate} ] ];
------------------------------------------------------
blueice 2003整理 http://hshlin.8u8.com
*************************************************
xupiao 2003-10-16
  • 打赏
  • 举报
回复
按你的鏈接查詢資料庫就可以找出你要的記錄
用表格顯示就可以了
富察咪咪 2003-10-16
  • 打赏
  • 举报
回复
先下载个程序学习一下
dafei0320 2003-10-16
  • 打赏
  • 举报
回复
这是连接数据库

<%
set conn=server.CreateObject("adodb.connection")
set rs=server.CreateObject("adodb.recordset")
cnpath="data source=" & server.MapPath("地址--")
conn.open "provider=microsoft.jet.oledb.4.0;" & cnpath
%>
goldme76 2003-10-15
  • 打赏
  • 举报
回复
你说的VBSCRIPT是不是指的ASP啊?

28,390

社区成员

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

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