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

doodoo 2000-07-22 10:45:00
我刚学asp,对于数据库的连接与显示不是很清楚,望哪位大侠的指点在下一二,不胜感激!
如何去建立数据库和怎样从数据库中调用数据,最好能给出一个小的程序,可以让我研究研究。谢谢!!
...全文
123 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
  • 打赏
  • 举报
回复
我给你发过去一个,你看看吧
本课程是SQL系列课程第2篇:MySQL数据。MySQL篇    MySQL数据管理系统安装        10.1 MySQL概述            10.1.1 MySQL主要特点            10.1.2 MySQL主要版本         10.2 MySQL数据安装和配置            10.2.1 Windows平台安装MySQL                1.下载MySQL8.0社区版                2.安装MySQL8.0社区版            10.2.2 Linux平台安装MySQL                1.更新软件仓库包索引                2.安装 MySQL                3.防火墙设置                4.启动 MySQL 服务                5.配置远程登录            10.2.3 macOS平台安装MySQL                1.下载MySQL8.0社区版                2.安装 MySQL    MySQL数据管理系统日常管理        11.1 登录服务器        11.2 常见的管理命令            11.2.1 帮助命令            11.2.2 退出命令            11.2.3 数据管理            11.2.4 用户管理        11.3 查看系统对象信息            11.3.1 查看有哪些库            11.3.2 查看有哪些表            11.3.3 查看表结构        11.4 执行脚本文件            11.4.1 不需要登录MySQL方式            11.4.2 需要登录MySQL方式        11.5 数据备份与恢复            11.5.1 备份数据            11.5.2 恢复数据            11.5.3 实例:在Windows下备份到Linux下恢复        11.6 MySQL图形界面管理工具            11.6.1 下载和安装MySQL Workbench            11.6.2 配置连接数据            11.6.3 管理数据            11.6.4 管理表            11.6.5 执行SQL语句    MySQL特有的SQL语句        12.1 自增长字段        12.2 MySQL日期相关数据类型        12.3 限制返回行数        12.4 常用函数            12.4.1 数字型函数            12.4.2 字符串函数            12.4.3 日期和时间函数    MySQL数据开发        13.1 存储过程            13.1.1 使用存储过程重构“找出所有销售部所有员工信息”案例            13.1.2 调用存储过程            13.1.3 删除储过程        13.2 存储过程参数            13.2.1 IN参数            13.2.2 OUT参数            13.2.3 INOUT参数        13.3 存储函数            13.3.1 创建存储函数            13.3.2 调用存储函数            13.3.3 删除存储函数        13.4 触发器            13.4.1 触发器分类            13.4.2 创建触发器语法            13.4.3 使用NEW和OLD修饰符            13.4.4 示例:员工表操作更新日志            13.4.5 测试触发器

28,390

社区成员

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

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