如何去建立数据库和怎样从数据库中调用数据

doodoo 2000-07-22 10:45:00
我刚学asp,对于数据库的连接与显示不是很清楚,望哪位大侠的指点在下一二,不胜感激!
如何去建立数据库和怎样从数据库中调用数据,最好能给出一个小的程序,可以让我研究研究。谢谢!!
...全文
124 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lzliming 2000-07-27
  • 打赏
  • 举报
回复
<%
sServer="xtgcb"
sLoginID="abc"
sPassword="123456"
sDatabase="lnwljc"
ConnectionString="provider=SQLoledb" & ";SERVER=" & sServer & ";UID=" & sLoginID & ";PWD=" & sPassword & ";DATABASE=" & sDatabase
%>
<%
set rs=Server.CreateObject("ADODB.Recordset")
rs.cursorlocation=3
sou="select fenjuma,mingzi from v_juj"
rs.open sou,ConnectionString,1,1,1
yearnumber=rs.recordcount

dim aju()
dim ajum()
dim awlsj()
redim aju(yearnumber-1)
redim ajum(yearnumber)
redim awlsj(yearnumber,yearnumber)
rs.movefirst
for i=0 to yearnumber-1
aju(i)=rs(0).value
ajum(i)=rs(1).value
rs.movenext
next
ajum(i)="合计"
set rs=nothing

for i=0 to ubound(awlsj)
for j=0 to ubound(awlsj)
awlsj(i,j)=0
next
next

dim amonth(11)
for i=0 to 11
amonth(i)=i+1
next

dim aday(31)
for i=0 to 30
aday(i)=i+1
next

dim akou(4)
akou(0)="永州"
akou(1)="黎塘"
akou(2)="可靠"
akou(3)="扩大"

set rs=Server.CreateObject("ADODB.Recordset")
rs.cursorlocation=3
sou="select year(riqi) from v_wlsj group by year(riqi) order by year(riqi) desc"
rs.open sou,ConnectionString,1,1,1
rs.movelast
rs.movefirst
yearnumber=rs.recordcount
dim ayear()
redim ayear(yearnumber-1)
for i=0 to yearnumber-1
ayear(i)=rs(0).value
rs.movenext
next
set rs=nothing


function sele(firstval,lastval)
if trim(firstval)=trim(lastval) then
sele="SELECTED"
end if
end function

function scanary(aaryl,chrzf)
dim si,sj
sj=-1
for si=0 to ubound(aaryl)
if trim(aaryl(si))=trim(chrzf) then
scanary=si
sj=1
exit for
end if
next
if sj=-1 then scanry=sj
end function
%>

<%
snian=request.form("nian")
syue1=request.form("yue1")
syue2=request.form("yue2")
sday1=request.form("day1")
sday2=request.form("day2")
skou=request.form("kou")

if isempty(snian) then snian=year(date())
if isempty(syue1) then syue1=month(date())
if isempty(sday1) then sday1=1
if isempty(syue2) then syue2=month(date())
if isempty(sday2) then sday2=day(date())
if isempty(skou) then skou=akou(0)
%>

<html>
<head>
<title>违流重车分析表</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link type="text/css" href="mystyle.css" rel=stylesheet title="mystyle">
</head>
<body bgcolor=#ffffff topmargin=5 marginheight=5 leftmargin=5 marginwidth=5 background="bg.gif">

<script language='javascript'>
window.status="dkfj"
</script>

<%
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select c.juming,c.fenjuma,b.juming,b.fenjuma,str(sum(zaizhong),11,0) "
sql=sql&"from v_wlsj a,v_zhanm b,v_zhanm c "
sql=sql&"where a.faming=b.zhanming and a.daoming=c.zhanming "
sql=sql&"and kouzi='"&scanary(akou,skou)+1&"' and "
sql=sql&"riqi>='"&snian&"."&syue1&"."&sday1&"' and "
sql=sql&"riqi<='"&snian&"."&syue2&"."&sday2&"'"
sql=sql&" group by b.juming,b.fenjuma,c.juming,c.fenjuma"
'response.write sql
rs.open sql,ConnectionString,1,1,1
%>

<table align=center width=100% border=0 cellspacing=0 cellpadding=0>
<tr><td align="center" valign=bottom height=30pt><font style="font-size:20pt;"><span style="color:#4274de;line-height:20pt;font-weight:bold;FILTER: glow(color=#3fbbef,strength=0) shadow(color=gray,direction=70); POSITION: relative; WIDTH: 100%">违流重车分析表</span></font></td>
<tr><td height=1 bgcolor=#4274de valign=top><img src=c.gif width=1 height=1></td>
</table>

<table border=0 cellspacing=0 cellpadding=0 align=center >
<tr height=14><th>
<form action="wl.asp" method="post">开始时间
<select name="nian" >
<%
for each var in ayear %>
<option <%=sele(var,snian)%>> <% =var %> </option>
<% next
%>
</select>

<select name="yue1" >
<%
for each var in amonth %>
<option <%=sele(var,syue1)%>> <% =var %> </option>
<% next
%>
</select>

<select name="day1" >
<%
for each var in aday %>
<option <%=sele(var,sday1)%>> <% =var %> </option>
<% next
%>
</select>
日至
<select name="yue2" >
<%
for each var in application("arymonth") %>
<option <%=sele(var,syue2)%>> <% =var %> </option>
<% next
%>
</select>

<select name="day2" >
<%
for each var in aday %>
<option <%=sele(var,sday2)%>> <% =var %> </option>
<% next
%>
</select>
日 检测口:
<select name="kou" >
<%
for each var in akou %>
<option <%=sele(var,skou)%>> <% =var %> </option>
<% next
%>
</select>
<input type=submit name=b1 value="确定">
</form>
</th>
</table>
<%

do while not rs.eof
i=scanary(aju,rs(0).value)
j=scanary(aju,rs(2).value)
if i<>-1 and j<>-1 then
awlsj(i,j)=awlsj(i,j)+rs(4).value
awlsj(i,ubound(awlsj))=awlsj(i,ubound(awlsj))+rs(4).value
awlsj(ubound(awlsj),j)=awlsj(ubound(awlsj),j)+rs(4).value
awlsj(ubound(awlsj),ubound(awlsj))=awlsj(ubound(awlsj),ubound(awlsj))+rs(4).value
if i=7 or i=14 then
d=scanary(aju,rs(1).value)
if d<>-1 then
awlsj(d,j)=awlsj(d,j)+rs(4).value
awlsj(d,ubound(awlsj))=awlsj(d,ubound(awlsj))+rs(4).value
end if
if j=7 or j=14 then
c=scanary(aju,rs(3).value)
if c<>-1 then awlsj(d,c)=awlsj(d,c)+rs(4).value
end if
else
if j=7 or j=14 then
c=scanary(aju,rs(3).value)
if c<>-1 then
awlsj(i,c)=awlsj(i,c)+rs(4).value
awlsj(ubound(awlsj),c)=awlsj(ubound(awlsj),c)+rs(4).value
end if
end if
end if
end if
rs.movenext
loop
set rs=nothing
%>
<table border=0 cellspacing=0 cellpadding=1 align=center bgcolor=#4274de width=630>
<tr><th>
<table border=0 cellspacing=1 cellpadding=3 align=center bgcolor=#ffffff width=630>
<colgroup align=center>
<colgroup align=right span=8>
<tr><td class=biao width=70>到 - 发</td>
<%
for i=0 to 7
response.write "<td class=biao width=70>"&ajum(i)&"</td>"
next
for i=0 to ubound(awlsj)
response.write "<tr><th class=biao>"&ajum(i)&"</th>"
for j=0 to 7
response.write "<th class=biao>"&awlsj(i,j)&"</th>"
next
next
%>
</table>
</th>
<tr><th bgcolor=#ffffff >续1:<br></th>
<tr><th>
<table border=0 cellspacing=1 cellpadding=3 align=center bgcolor=#ffffff width=630>
<colgroup align=center>
<colgroup align=right span=8>
<tr><td class=biao width=70>到 - 发</td>
<%
for i=8 to 15
response.write "<td class=biao width=70>"&ajum(i)&"</td>"
next
for i=0 to ubound(awlsj)
response.write "<tr><th class=biao>"&ajum(i)&"</th>"
for j=8 to 15
response.write "<th class=biao>"&awlsj(i,j)&"</th>"
next
next
%>
</table>
</th>
<tr><th bgcolor=#ffffff>续2:<br></th>
<table border=0 cellspacing=0 cellpadding=1 align=center bgcolor=#4274de width=630>
<tr><th>
<table border=0 cellspacing=1 cellpadding=3 align=center bgcolor=#ffffff width=630>
<colgroup align=center>
<colgroup align=right span=8>
<tr><td class=biao width=70>到 - 发</td>
<%
for i=16 to 23
response.write "<td class=biao width=70>"&ajum(i)&"</td>"
next
for i=0 to ubound(awlsj)
response.write "<tr><th class=biao width=70>"&ajum(i)&"</th>"
for j=16 to 23
response.write "<th class=biao>"&awlsj(i,j)&"</th>"
next
next
%>
</table>
</th>
</table>
</body>
Tyro 2000-07-22
  • 打赏
  • 举报
回复
我给你发过去一个,你看看吧

28,390

社区成员

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

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