|
-
Dec 28th, 2005, 09:41 AM
#1
Thread Starter
Hyperactive Member
classes
Hi friends,
I am searching information about how to make a simpel class in asp but i cna't figure it out. I have a couple of examples but i don't understand them as good to make my own or they are to complicated. I simply need a class for mysql database. I am now doing al the connection and sql things in every page but i need to have one file with the class that i can include.
What i need to do is very simpel. with the class for example..
class.connect
firstname = class.lastname("batman")
with that firstname i have to use it like => firstname.movefirst etc...
class.new_firstname(firstname, lastname) (must give value 1 back or error)
class.exeq_sql (sql string)
class.close_connection
is there someone who can help me or have a good and simpel example?
Thanks a lot,
Matrixxx
-
Dec 28th, 2005, 10:16 AM
#2
Fanatic Member
Re: classes
Hi,
heres some sample code that wil initialise variables set objects and then use a section of functions to instantiate the class and initializwe the subs within the class.
A good book on classes adn good object coding in ASP adn VBscript is
VBScript programmers reference from Wrox press
Enjoy!!!
VB Code:
call func_init() // initialises trhe entire program
VB Code:
class classname
dim var1
dim var2
dim var3
public sub connect
set var1 = server.createobject(2ADODB.Connection")
var3 = //SQL
end sub
public sub exe_connect
var1.execute (var3)
set var1 = nothing
end sub
end class
private function class_init()
dim classvar
set classvar = new classname
session("hello") = request.form("hello")
var3 = request.form("hello")
end function
so youve got all your code there then you can use summat like this to initialize it.
VB Code:
public function func_init()
if var3 <> "" then
class_init()
classvar.connect
classvar.exe_connect
end function
So as you can see everythign within tehclass is done in subs and all have to follow the rules of public and private.
Hope this helps
Kai
As the information I give is useful in its nature, consider using the RATE POST feature located on the bottom left of this post please..
A few things that make a good Developer a Great One.
Methodical and a thorough approach to research and design inevitably leads to success.
Forward thinking is the key to Flow of control.
Never test in the design environment, always test in real time, you get the REAL results.
CBSE & OOSE are the same animal, they just require different techniques, and thinking.
SEO is a globe of objectives, SE rankings is an end to a means for these objectives, not part of them.
The key to good design is explicit attention to both detail and response.
Think Freely out of the "Box" you're in..... You will soar to better heights.
Kai Hirst - MSCE, MCDBA, MCSD, MCP, MCAP, MSCT
-
Dec 28th, 2005, 02:13 PM
#3
Thread Starter
Hyperactive Member
Re: classes
 Originally Posted by kaihirst
Hi,
heres some sample code that wil initialise variables set objects and then use a section of functions to instantiate the class and initializwe the subs within the class.
A good book on classes adn good object coding in ASP adn VBscript is
VBScript programmers reference from Wrox press
Enjoy!!!
...
Yes great it works and i understand now. thanks man!!
Matrixxx
-
Dec 30th, 2005, 04:13 PM
#4
Fanatic Member
Re: classes
Great!!
Glad to hea that I helped. Dont forget to mark this as resolved and rate me a little please.
good luck
Kai
As the information I give is useful in its nature, consider using the RATE POST feature located on the bottom left of this post please..
A few things that make a good Developer a Great One.
Methodical and a thorough approach to research and design inevitably leads to success.
Forward thinking is the key to Flow of control.
Never test in the design environment, always test in real time, you get the REAL results.
CBSE & OOSE are the same animal, they just require different techniques, and thinking.
SEO is a globe of objectives, SE rankings is an end to a means for these objectives, not part of them.
The key to good design is explicit attention to both detail and response.
Think Freely out of the "Box" you're in..... You will soar to better heights.
Kai Hirst - MSCE, MCDBA, MCSD, MCP, MCAP, MSCT
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|