ASP类,代码包含多次 - 如何避免? [英] ASP classes, code included multiple times - how to avoid?

查看:58
本文介绍了ASP类,代码包含多次 - 如何避免?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个ASP应用程序并且有一个noob问题...


我有一个访问MS SQL数据库的类。我还有另一个类

访问MS SQL数据库,第二个类使用

第一类中的对象。我有第三个类使用数据库和第二个

类的对象。


这些类中的每一个都包含访问数据库所需的所有代码和

这意味着很多重复的代码。我想知道的是,有没有办法

来避免重复的代码?


我知道我可以编写一次代码,然后做#include将代码

包含在类中,但这仍然意味着代码的多次出现。


???

I''m writing an ASP application and have a noob question...

I have a class that access an MS SQL database. I have another class also
accesses an MS SQL database and this second class uses objects from the
first class. I have a third class using the DB and objects of the second
class.

Each of these classes contain all the code needed to access the database and
this means much duplicated code. What I''d like to know is if there is a way
to avoid the duplicated code?

I know I could write the code once, then do an #include to include the code
into the class, but that still means multiple occurances of the code.

???

推荐答案

Noozer写道:
我正在写一个ASP应用程序并且有一个noob问题...
我有一个访问MS SQL数据库的类。我有另一个类
也访问MS SQL数据库,第二个类使用第一个类的对象。我有第三个类使用DB和第二类的对象。

这些类中的每一个都包含访问
数据库所需的所有代码,这意味着很多重复的代码。我想知道
是否有办法避免重复的代码?

我知道我可以编写一次代码,然后执行#include以包含
代码进入类,但这仍然意味着代码的多次出现。
I''m writing an ASP application and have a noob question...

I have a class that access an MS SQL database. I have another class
also accesses an MS SQL database and this second class uses objects
from the first class. I have a third class using the DB and objects
of the second class.

Each of these classes contain all the code needed to access the
database and this means much duplicated code. What I''d like to know
is if there is a way to avoid the duplicated code?

I know I could write the code once, then do an #include to include
the code into the class, but that still means multiple occurances of
the code.




你是什么意思class ?你在谈论VBScript Class Objects
使用Class语句创建的


http://msdn.microsoft.com/library/en...1f669ec5.asp)?

你的意思是用JScript编写的自定义对象?您使用Server.CreateObject(" prog.id")实例化的ActiveX对象?

-

Dave Anderson


未经请求的商业电子邮件将以每封邮件



What do you mean by "class" ? Are you talking about VBScript Class Objects
created by using the Class Statement
(http://msdn.microsoft.com/library/en...1f669ec5.asp)?
Do you mean custom objects written in JScript? ActiveX objects you
instantiate with Server.CreateObject("prog.id")?
--
Dave Anderson

Unsolicited commercial email will be read at a cost of


500的成本读取。使用

此电子邮件地址即表示同意这些条款。请不要直接联系

我或要求我直接与您联系以获取帮助。如果你的问题值得询问,那就值得发帖了。
500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it''s worth posting.




" Dave Anderson" < GT ********** @ spammotel.com>在消息中写道

新闻:12 ************ @ corp.supernews.com ...

"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:12************@corp.supernews.com...
Noozer写道:
我正在写一个ASP应用程序并且有一个noob问题...
< snip>这些类中的每一个都包含访问
数据库所需的所有代码,这意味着许多重复的代码。我想知道
是否有办法避免重复的代码?
I''m writing an ASP application and have a noob question... <snip> Each of these classes contain all the code needed to access the
database and this means much duplicated code. What I''d like to know
is if there is a way to avoid the duplicated code?


你是什么意思class ?您是在谈论使用类声明创建的VBScript类对象
http://msdn.microsoft.com/library/en...1f669ec5.asp)?




是的,确切地说。



Yes, exactly.


这篇关于ASP类,代码包含多次 - 如何避免?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆