Results 1 to 4 of 4

Thread: classes

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    259

    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

  2. #2
    Fanatic Member kaihirst's Avatar
    Join Date
    Jul 2005
    Location
    The Resaurant At the End of The Universe
    Posts
    633

    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:
    1. call func_init() // initialises trhe entire program

    VB Code:
    1. class classname
    2.  
    3. dim var1
    4. dim var2
    5. dim var3
    6.  
    7. public sub connect
    8.  
    9. set var1 = server.createobject(2ADODB.Connection")
    10.  
    11. var3 = //SQL  
    12.  
    13. end sub
    14.  
    15. public sub exe_connect
    16.  
    17. var1.execute (var3)
    18.  
    19. set var1 = nothing
    20.  
    21. end sub
    22.  
    23. end class
    24.  
    25. private function class_init()
    26.  
    27. dim classvar
    28. set classvar = new classname
    29.  
    30. session("hello") = request.form("hello")
    31. var3 = request.form("hello")
    32.  
    33. end function

    so youve got all your code there then you can use summat like this to initialize it.

    VB Code:
    1. public function func_init()
    2.  
    3. if var3 <> "" then
    4. class_init()
    5.  
    6. classvar.connect
    7. classvar.exe_connect
    8.  
    9. 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


  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    259

    Re: classes

    Quote 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

  4. #4
    Fanatic Member kaihirst's Avatar
    Join Date
    Jul 2005
    Location
    The Resaurant At the End of The Universe
    Posts
    633

    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
  •  



Click Here to Expand Forum to Full Width