Results 1 to 5 of 5

Thread: execute stored procedure in a class

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2008
    Posts
    47

    execute stored procedure in a class

    Hi vbforums. Im a vb 6 newbie. Is it advisable to execute a stored procedure
    inside a class

    for example:

    form
    -------------------------
    set cSaveDB = new clsSave

    cSaveDB.SetName = txtName
    cSaveDB.SetAge = txtAge
    cSaveDB.WritetoDB



    class module
    -------------------------
    Public Sub WritetoDB

    set qy = new ADODB.command
    Set qy.activeConnection = cn
    qy.commandtext = "sp_Save"
    qy.commandType = adCmdStoredPRoc
    with qy

    .value(1) = Name
    .value(2) = Age

    end with
    set rs = qy.Execute

    End Sub

    is this a good practice in using class module?

    Thanks a lot

  2. #2
    Hyperactive Member
    Join Date
    Jan 2008
    Location
    Merseyside
    Posts
    456

    Re: execute stored procedure in a class

    The fact that your seperating out the data layer from the presentation is a good thing.

    but...

    As your a newbie, i would suggest you consider forgetting about VB6 and learning VB.NET instead as VB6 is getting long in the tooth!

  3. #3
    Lively Member KTech's Avatar
    Join Date
    Jun 2008
    Location
    Pittsburgh
    Posts
    117

    Re: execute stored procedure in a class

    Yes, keeping the sql in the database and not in the code is definitely the better way to go. When you make changes to the database in the future you can easily list all of your stored procedures and make appropriate updates. It is much easier than searching millions of lines of code to find sql statements.

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: execute stored procedure in a class

    you may want to read our DB FAQ and tutorial thread... has lots of info for the beginner.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2008
    Posts
    47

    Re: execute stored procedure in a class

    Thanks a lot for all your tips. It helped me a lot thinking of new concepts.

Tags for this Thread

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