仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 3393|回复: 18
打印 上一主题 下一主题

[学习教程] ASP编程:显示数据库中的存储进程

[复制链接]
飘灵儿 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-2-16 00:25:34 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
专业性的服务。有的ASP商提供垂直型的应用服务,针对某一特定行业提供应用服务。存储进程|数据|数据库|显示   It's no easy trick to see stored procedures in a database programmatically with a scripting language like ASP. If you're using MS Access, you're out of luck. Access provides no way to see the actual meat of a stored procedure although you can get the names of the procedures in the database with the ADOX.Catalog COM object.

But, if you are using SQL Server (like you should be because you care about your data), you have a guaranteed way to view all your stored procedures using two globally-available system objects: the built-in sysobjects system table and the sp_helptext system stored procedure.

With a couple of simple loops, everything about your stored procedures can be viewed and accessed programmatically in just a few lines. Here's the results of the function (I'm allowing you to view the first few procedures only because this method can be pretty resource-intensive. If you want the complete list of procedures I use on this site, you can get it here.) Here's how it looks when called:


CREATE PROCEDURE sp_addAdvertLink
(
@m1 DateTime,
@m2 DateTime,
@m3 VarChar(20),
@m4 VarChar(20),
@m5 VarChar(255),
@m6 VarChar(255),
@m7 VarChar(255),
@m8 VarChar(255)
)
AS
INSERT INTO
easyAds
(
display_date, display_time, display_month, display_day,
usr_ip_address, usr_browser, display_adName, usr_referer
)
VALUES
(
@m1, @m2, @m3, @m4, @m5, @m6, @m7, @m8
)


CREATE PROCEDURE sp_AddMailRecip
(
@mIPAddr VarChar(255),
@mEmailAddr VarChar(255)
)
AS
INSERT INTO
autoResponder
(
IPaddress, emailAddress
)
VALUES
(
@mIPAddr, @mEmailAddr
)


CREATE PROCEDURE sp_addUsrAddr
(
@mUsr VarChar(255),
@mFstNme VarChar(255),
@mLastNme VarChar(255),
@mAddr1 VarChar(255),
@mAddr2 VarChar(255),
@mcity VarChar(255),
@mstate VarChar(255),
@mzip VarChar(255),
@mEmail VarChar(255),
@mphone VarChar(255),
@mfax VarChar(255),
@mcell VarChar(255),
@mnotes Text
)
AS
INSERT INTO
dayPlannerAddresses
(
usr, firstname, lastname, streetAddress1, streetAddress2,
city, state, zip, eMailAddress, phone, fax, cell, notes
)
VALUES
(
@mUsr, @mFstNme, @mLastNme, @mAddr1, @mAddr2, @mcity, @mstate,
@mzip, @mEmail, @mphone, @mfax, @mcell, @mnotes
)


------------------sysobjects.asp-------------源法式--------------

<% @ Language = JScript %>
<%
with (Response) {
Buffer = true;
Expires = 0;
Clear();
}

function ShowProcs() {
//set-up database connection information
var ConnString = Application("dbConn");
var ConnUser = Application("dbUsr");
var ConnPass = Application("dbPass");

//set this next variable to false to unrestrict the system
var LimitResults = true;
var MagicNumber = 2;

//get a connection
var c = new ActiveXObject("ADODB.Connection");

//open database
c.Open(ConnString, ConnUser, ConnPass);

//enable error-trapping
try {

//attempt to access the sysobjects table.
//if you try this with MS Access, you will get an error...

//sysobjects table contains information about everything
//in your database. From tables to views, and whatever in
//between, all that stuff is in the sysobjects table.

//in my db, a status of 24 indicates that it's a procedure
//that I added and not one of the other bizarre stored procedures
//that were mixed in there as well. A type of P indicates Stored Procedure.
//Other values for type can be 'U' for user tables, 'R' for rule,
//'s' for system tables (like sysobjects), 'TR' for triggers, 'V' for view, //etc... In this case 'P' is the one we want.
var p = c.Execute("SELECT Name FROM sysobjects WHERE status = 24 AND type = 'P' ORDER BY Name;");
} catch(e) {

//oops - sysobjects table not found. You must be using MS Access.
//Or you forgot to re-code the connection string.
Response.Write("This example only works with <B>SQL Server");
Response.Write("</B>. \"sysobjects\" table does not exist!<BR><BR>");
Response.Write("If you are using SQL server, you may need to ");
Response.Write("adjust the ConnString, ConnUser and ConnPass variables ");
</p>  asp,jsp,php是web开发的三大技术,asp简单易用且有microsoft做靠山,jsp功能强大是因为有java支持,php则开源跨平台.在国内,asp应用范围最广,jsp发展势头最猛,php则处于劣势.这可能与公司的支持以及技术的培训有关.
愤怒的大鸟 该用户已被删除
沙发
发表于 2015-2-16 01:35:28 | 只看该作者
封装性使得代码逻辑清晰,易于管理,并且应用到ASP.Net上就可以使业务逻辑和Html页面分离,这样无论页面原型如何改变,业务逻辑代码都不必做任何改动;继承性和多态性使得代码的可重用性大大提高。
只想知道 该用户已被删除
板凳
发表于 2015-3-1 16:49:58 | 只看该作者
我们必须明确一个大方向,不要只是停留在因为学而去学,我们应有方向应有目标.
小魔女 该用户已被删除
地板
发表于 2015-3-3 10:59:21 | 只看该作者
封装性使得代码逻辑清晰,易于管理,并且应用到ASP.Net上就可以使业务逻辑和Html页面分离,这样无论页面原型如何改变,业务逻辑代码都不必做任何改动;继承性和多态性使得代码的可重用性大大提高。
再见西城 该用户已被删除
5#
发表于 2015-3-5 16:54:55 | 只看该作者
我就感觉到ASP和一些常用的数据库编程以及软件工程方面的思想是非常重要的。我现在也在尝试自己做网页,这其中就用到了ASP,我想它的作用是可想而知的。
海妖 该用户已被删除
6#
发表于 2015-3-8 23:04:24 | 只看该作者
虽然ASP也有很多网络教程。但是这些都不系统。都是半路出家,只是从一个例子告诉你怎么用。不会深入讨论,更不会将没有出现在例子里的方法都一一列举出来。
冷月葬花魂 该用户已被删除
7#
发表于 2015-3-12 14:20:49 | 只看该作者
代码的可重用性差:由于是面向结构的编程方式,并且混合html,所以可能页面原型修改一点,整个程序都需要修改,更别提代码重用了。
小女巫 该用户已被删除
8#
发表于 2015-3-17 02:09:27 | 只看该作者
代码的可重用性差:由于是面向结构的编程方式,并且混合html,所以可能页面原型修改一点,整个程序都需要修改,更别提代码重用了。
活着的死人 该用户已被删除
9#
发表于 2015-3-23 08:57:41 | 只看该作者
代码逻辑混乱,难于管理:由于ASP是脚本语言混合html编程,所以你很难看清代码的逻辑关系,并且随着程序的复杂性增加,使得代码的管理十分困难,甚至超出一个程序员所能达到的管理能力,从而造成出错或这样那样的问题。
柔情似水 该用户已被删除
10#
发表于 2015-3-29 17:14:48 | 只看该作者
如何更好的使自己的东西看上去很不错等等。其实这些都不是问题的实质,我们可以在实践中不断提升自己,不断充实自己。
透明 该用户已被删除
11#
发表于 2015-4-13 13:48:22 | 只看该作者
先学习用frontpage熟悉html编辑然后学习asp和vbscript建议买书进行系统学习
若相依 该用户已被删除
12#
发表于 2015-4-13 16:10:50 | 只看该作者
最近在学asp,不要问我为什么不直接学.net,因为公司网站是asp做的所以有这个需要,卖了本书asp入门到精通,对里面的六大内置对象老是记不住,还有很多属性和方法看的头晕。
精灵巫婆 该用户已被删除
13#
发表于 2015-4-16 22:24:21 | 只看该作者
如何学好ASP,以前也有人问过,把回答给你转过来看看能否对你有帮助:
admin 该用户已被删除
14#
发表于 2015-4-21 21:29:09 | 只看该作者
接下来就不能纸上谈兵了,最好的方法其实是实践。实践,只能算是让你掌握语言特性用的。而提倡做实际的Project也不是太好,因为你还没有熟练的能力去综合各种技术,这样只能使你自己越来越迷糊。
金色的骷髅 该用户已被删除
15#
发表于 2015-4-26 22:11:50 | 只看该作者
我认为比较好的方法是找一些比较经典的例子,每个例子比较集中一种编程思想而设计的。
灵魂腐蚀 该用户已被删除
16#
发表于 2015-6-14 21:29:22 | 只看该作者
Session:这个存储跟客户端会话过程的数据,默认20分钟失效
17#
发表于 2015-7-5 22:39:40 | 只看该作者
Application:这个存储服务端的数据,如果不清除,会直到web应用程序结束才清除(例如重启站点)
简单生活 该用户已被删除
18#
发表于 2015-7-9 05:24:33 | 只看该作者
还有如何才能在最短的时间内学完?我每天可以有效学习2小时,双休日4小时。
爱飞 该用户已被删除
19#
发表于 2015-9-26 00:55:07 | 只看该作者
ASP(ActiveServerPages)是Microsfot公司1996年11月推出的WEB应用程序开发技术,它既不是一种程序语言,也不是一种开发工具,而是一种技术框架,不须使用微软的产品就能编写它的代码,能产生和执行动态、交互式、高效率的站占服务器的应用程序。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-4-27 09:16

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表