ASP语言实现对SQLSERVER数据库的操作
更新时间:2022年05月05日 10:51:42 投稿:lijiao
目前有很多介绍用ASP开发网络数据库的程序例子,但绝大部分是利用ACCESS作底层数据库。相对于ACCESS而言,SQLSERVER数据库系统要复杂得多,因此在程序开发中需要多做一些工作。笔者结合自己开发管理信息系统的经验,在此试举一例,与感兴趣的朋友共同交流
目前管理信息系统已从传统的客户机/服务器(C/S)模式转向了浏览器/服务器(B/S)模式,特别是微软公司推出它的新产品ASP语言之后,这种转变更加迅猛。管理信息系统的核心是对数据库进行包括添加、修改和查询等等操作,ASP提供的ADO数据库接口控件,使得程序员再也勿需编写复杂的CGI程序了,而只要用几句简单的语句即可实现以上操作。
1、系统环境
PII 350,Ram 64M,WINNT Server 4.0,
Service Pack4, IIS 4.0, SQL Server7.0。
2、系统功能
通过使用IE浏览器,在网上实现对《办公文件》数据表记录的添加和查询。
3、功能实现
(1)数据表的设置
①启动SQL Server7.0的Enterprise Manager,
在Databases 目录下增加一个新子目录"test";
②在"test"下增加一个new table,名为"办公文件",字段设置:文件名asp数据库,char,100,允许空;文件内容,char,4000,允许空。
③在SQL Server中增加一个用户,名为hxl, 密码为123,登录模式为SQL 登录,将其默认登录数据库设为"test";
④在"test"数据库下增加一个新用户,名为hxl,其角色设为"Dbowner"。
(2)ODBC 链接
①在控制面板中,打开ODBC数据源,选择系统DSN项,单击"添加";
②选择"SQL Server"数据源,命名为"test";
③选择登录模式为SQL Server验证,登录标志为"hxl",密码为"123";
④将默认数据库高为"test",再测试数据库链接,接通即可。
(3)程序文件
为了实现系统功能,在这里编辑了3个程序文件,分别为"index.html"、"add.asp"和"query.asp",具体内容如下:
①index.html:系统首页,包括两个选项,一是追加记录,二是查询,用户可单击两者之一,即可进入相应的操作过程。以下是源程序:
示例程序
欢迎使用用ASP语言对SQL
SERVER数据库操作示例
追加记录< /a >
查 询
②add.asp:实现对《办公文件》数据表记录的添加。页面中含有一个单行文本框(Txtbiaoti)和一个滚动文本框(Txtneirong),分别用来输入文件标题和文件内容。此外,页面中还应有两个按钮,"确定(Cmdok)"和"重写(Cmdcancel)",单击"确定"完成记录追加,单击"重写"重新输入内容。以下是源程序:
追加一条新记录
<% if request.form("cmdok")="确定" then % >
<%
set dbconnection=server.createobject
("adodb.connection") dbconnection.open"test","hxl","123"
sqlquery="insert "办公文件"
(文件名,文件内容)
values ('request.form("Txtbiaoti")','
request.form("Txtneirong")')
set recadd=dbconnection.execute(sqlquery) % >
<% else % >
追加记录
<% end if%>
③query.asp:实现对《办公文件》数据表记录的查询。程序仅实现对《办公文件》中"文件名"的查询,查询结果用一个表单(Table)列出。以下是源程序:
检索文件< /title>
</head>
<body bgcolor="#ffffdd">
<%
set dbconnection=server.createobject
("adodb.connection")
dbconnection.open "test","hxl","123"
sqlquery="SELECT 文件名 FROM 办公文件 "
set resultlist=dbconnection.execute(sqlquery)
%>
<center>
<font color="red"><%=request("selectsource")%>
</font><font color="#008000" size="5"><b>
有以下文件可供阅览</b></font>
<hr size="5">
<table border="1">
<tr>
<td width="200" align="center"><b>
文件名 </b> </td>
</tr>
<% do while not resultlist.eof %>
<tr>
< td valign=center width="200"><%=resultlist
("文件名")% ></a></td>
</tr>
<%
resultlist.movenext
loop
resultlist.close
%>
</center>
</TABLE>
</body>
</html></pre></p>
<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em;'>总结</p>
<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em;'>用IE打开index.html或将文件发布到站点,进行相应的操作,即可实现对SQL Server数据库系统中《办公文件》数据表记录的追加和查询,至此系统目标已经达到。</p>
<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em;'>以上就是用ASP语言实现对SQL SERVER 数据库的操作,希望获得更多这方面内容的童鞋可以阅读相关文章。</p>
<p style="text-align:right;">(编辑:老爷爷站长网)</p>
<p style="text-align:right;">【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!</p>
</td>
</tr>
</table>
</div>
<div class="dede_pagess"><ul class="pagelist"></ul></div>
<div class="ad-690"><script src='https://ess.0577qiche.com/d/js/acmsd/ad76.js' language='javascript'></script></div>
<div class="g-box10">
<div class="t-2">相关内容</div>
<ul class="b-box12"></ul>
<ul class="b-box13"><li><a href="https://www.laoyeye.com.cn/html/jc/asp/2020/1205/254879.html" target="_blank">与城市共生长,中建方寸间招商发布会12.2荣耀启航</a></li><li><a href="https://www.laoyeye.com.cn/html/jc/asp/2020/1212/256427.html" target="_blank">冬季装修好处多,美家美沪金牌保价卡为你2021年保驾护航!</a></li><li><a href="https://www.laoyeye.com.cn/html/jc/asp/2020/1112/250144.html" target="_blank">勇克时艰 逆势发展 “羽顺杯”2020中国暖通行业品牌评选网络</a></li><li><a href="https://www.laoyeye.com.cn/html/jc/asp/2019/0205/111797.html" target="_blank">雅迪成功挑战川藏线 刷新行业新高度</a></li><li><a href="https://www.laoyeye.com.cn/html/jc/asp/2020/0110/174938.html" target="_blank">“史上最严”召回政策出台,家电业洗牌将至</a></li><li><a href="https://www.laoyeye.com.cn/html/jc/asp/2019/0204/111608.html" target="_blank">e换电CEO黄嘉曦:好的产品不畏资本寒冬</a></li><li><a href="https://www.laoyeye.com.cn/html/jc/asp/2022/0109/300182.html" target="_blank">asp自动刷新页面的完成方法总结</a></li><li><a href="https://www.laoyeye.com.cn/html/jc/asp/2020/1208/255518.html" target="_blank">你好,李菲儿</a></li><li><a href="https://www.laoyeye.com.cn/html/jc/asp/2020/1210/255777.html" target="_blank">未来居酒店智能化解决方案亮相中国酒店品牌高峰论坛</a></li><li><a href="https://www.laoyeye.com.cn/html/jc/asp/2020/0709/231807.html" target="_blank">万润科技、昕诺飞、兆驰、三安、木林森、华灿、晶台股份等大</a></li><div class="cl"></div></ul>
</div>
</div>
</div>
<div class="right-1 fr">
<div class="g-box8">
<div class="t-2">推荐文章</div>
<ul><table width=100% border=0 cellpadding=3 cellspacing=0><tr><td align=center><a href='https://www.laoyeye.com.cn/html/jc/asp/2022/0109/300015.html' target=_blank><img src='/uploads/allimg/c200902/15c005C9330F-13208.gif' width='135' height='90' border=0 alt='ASP中运用OWC控件实现图表功能详解'><br><span style='line-height:15pt'>ASP中运用OWC控件实现</span></a></td><td align=center><a href='https://www.laoyeye.com.cn/html/jc/asp/2022/0109/300013.html' target=_blank><img src='/uploads/allimg/c200902/15c005C9330F-13208.gif' width='135' height='90' border=0 alt='用asp远程执行指令'><br><span style='line-height:15pt'>用asp远程执行指令</span></a></td></tr><tr><td align=center><a href='https://www.laoyeye.com.cn/html/jc/asp/2022/0108/299907.html' target=_blank><img src='/uploads/allimg/c220108/1641A204Z010-14548.jpg' width='135' height='90' border=0 alt='每个asp程序员必懂的知识'><br><span style='line-height:15pt'>每个asp程序员必懂的知</span></a></td><td align=center><a href='https://www.laoyeye.com.cn/html/jc/asp/2022/0108/299905.html' target=_blank><img src='/uploads/allimg/c200902/15c005C9330F-13208.gif' width='135' height='90' border=0 alt='ASP创建Access表或增加字段'><br><span style='line-height:15pt'>ASP创建Access表或增加</span></a></td></tr></table></ul>
</div>
<div class="g-box11">
<div class="t-2">站长推荐</div>
<ul class="b-box7"><li><a href="https://www.laoyeye.com.cn/html/jc/asp/2022/0109/300184.html" target="_blank">ASP代码 隐秘图片的真实地址</a></li><li><a href="https://www.laoyeye.com.cn/html/jc/asp/2019/1201/162064.html" target="_blank">iphonex的a11处理器参数 苹果a11处理器和a10性能</a></li><li><a href="https://www.laoyeye.com.cn/html/jc/asp/2020/1212/256276.html" target="_blank">产品升级,泰拉蒙专业除醛效果看得见!</a></li><li><a href="https://www.laoyeye.com.cn/html/jc/asp/2020/1202/253916.html" target="_blank">中国财富史诗级转折,家居行业如何把控风口?</a></li><li><a href="https://www.laoyeye.com.cn/html/jc/asp/2020/1219/257473.html" target="_blank">雨洁携手全新品牌代言人电竞流量担当Uzi,专注“</a></li><li><a href="https://www.laoyeye.com.cn/html/jc/asp/2020/0818/236626.html" target="_blank">“智能安防”如何成为了智能家居的“前沿阵地”?</a></li><li><a href="https://www.laoyeye.com.cn/html/jc/asp/2019/1203/162916.html" target="_blank">考拉与袋鼠启示录:中国家居业的大局观和小趋势</a></li><li><a href="https://www.laoyeye.com.cn/html/jc/asp/2020/0910/239515.html" target="_blank">光峰和极米,为何从对手变成队友?</a></li><li><a href="https://www.laoyeye.com.cn/html/jc/asp/2020/0426/208915.html" target="_blank">疫情之下家电出口受冲击,但不能被“打败”</a></li><li><a href="https://www.laoyeye.com.cn/html/jc/asp/2020/1210/255961.html" target="_blank">在家速享温泉浴,美的UV光净燃气热水器还原自然水</a></li></ul>
</div>
<script type="text/javascript">jQuery(".g-box8").slide({ titCell:"li",triggerTime:0 }); </script>
<div class="ad-250"><script src='https://ess.0577qiche.com/d/js/acmsd/ad103.js' language='javascript'></script></div>
<div class="g-box3 u-3">
<div class="t-1">热点阅读</div>
<ul class="b-box2"><li class="no1"><a href="https://www.laoyeye.com.cn/html/jc/asp/314563.html" title="小型ASP服务器">小型ASP服务器</a></li><li class="no2"><a href="https://www.laoyeye.com.cn/html/jc/asp/314564.html" title="让IIS Web服务器不再拒认ASP网页">让IIS Web服务器不再拒认ASP网页</a></li><li class="no3"><a href="https://www.laoyeye.com.cn/html/jc/asp/314565.html" title="ASP.NET数据库操作类实例">ASP.NET数据库操作类实例</a></li><li class="no4"><a href="https://www.laoyeye.com.cn/html/jc/asp/314571.html" title="ASP下的常用数据库存取技术的实现">ASP下的常用数据库存取技术的实现</a></li><li class="no5"><a href="https://www.laoyeye.com.cn/html/jc/asp/314581.html" title="用ASP连接各种数据库的方法(经典)">用ASP连接各种数据库的方法(经典)</a></li><li class="no6"><a href="https://www.laoyeye.com.cn/html/jc/asp/314673.html" title="小旋风asp服务器数据库">小旋风asp服务器数据库</a></li><li class="no7"><a href="https://www.laoyeye.com.cn/html/jc/asp/314675.html" title="asp如何连接sql数据库?">asp如何连接sql数据库?</a></li><li class="no8"><a href="https://www.laoyeye.com.cn/html/jc/asp/314677.html" title="简述如何运行asp程序(编写asp程序)">简述如何运行asp程序(编写asp程序)</a></li><li class="no9"><a href="https://www.laoyeye.com.cn/html/jc/asp/314678.html" title="asp服务器 ASP的价值">asp服务器 ASP的价值</a></li><li class="no10"><a href="https://www.laoyeye.com.cn/html/jc/asp/314681.html" title="Asp.net 在本地服务器上托管Web应用程序">Asp.net 在本地服务器上托管Web应用程序</a></li></ul>
</div>
<div class="ad-250"><script src='https://ess.0577qiche.com/d/js/acmsd/ad77.js' language='javascript'></script></div>
</div>
<div class="cl"></div>
</div>
<div class="ad-960"><script src='https://ess.0577qiche.com/d/js/acmsd/ad78.js' language='javascript'></script></div>
<div class="footer">
<p>【免责声明】本站内容转载自互联网,其发布内容言论不代表本站观点,如果其链接、内容的侵犯您的权益,烦请提交相关链接至邮箱bqsm@foxmail.com我们将及时予以处理。</p>
<p>建议您使用1920×1080分辨率、谷歌浏览器Google Chrome、Microsoft Edge以获得本站的最佳浏览效果</p>
<p>Copygight © 2014-2022 https://www.laoyeye.com.cn/ All Rights Reserved. 老爷爷站长网</p>
<p><script type="text/javascript" src="//js.users.51.la/21280179.js"></script></p>
</div>
</body>
</html> |