Results 1 to 5 of 5

Thread: Another stupid ?

  1. #1

    Thread Starter
    Member
    Join Date
    May 2001
    Posts
    38

    Question Another stupid ?

    Ok this is probably a really stupid question..but since I'm only a student ...I'm supposed to ask stupid questions....I am working on a school project and I have to add a separate component to my project which accesses my sql database (actually two separate components...one for the connection, and one to retrieve data)....how should I go about doing this?? I was thinking I should build them as active x dll's ....is that correct? or should I be using something else??? For the connection component I have to pass over the user name and pass word from text boxes.....just really have no clue on the code to go inside the component...HELP!


    Cujo3131

  2. #2
    Fanatic Member
    Join Date
    Jan 2001
    Location
    Vietnam
    Posts
    613
    cujo3131,

    There is no stupid question, only silly answer!

    For your case, I think you just need to create one class in your project.

    The class will have properties to store the user name, password, and recordset. For simple project, you don't need to build ActiveX DLL.

    Regards,
    TheBao

  3. #3

    Thread Starter
    Member
    Join Date
    May 2001
    Posts
    38
    I'm aware that there is easier ways of doing this...but the project specifaccally says that the connection and the test generator should be separate components....and when I asked the teacher he had said the way I should be going is to make them active x dll's...now I'm lost!


    Cujo

  4. #4
    Fanatic Member
    Join Date
    Jan 2001
    Location
    Vietnam
    Posts
    613
    cujo3131,

    Please do the following:

    1. Start with a standard project.
    2. Create a class clsDataBase
    3. Inside clsDatabase, you should have the following properties and method:
    PROPERTIES:
    - strConnection: to store your connection string
    METHODS:
    - EstablishConnection(): to connect to database
    - GetResultA() As ADODB.Recordset: this will return you the recordset.
    Inside this function, you can have command object to run stored
    procedure... or you can just use inline SQL.
    - GetResultB() As ADODB.Recordset: this will return another recordset..
    4. In your form code, you can create the instance of this class as follow:
    Dim objDatabase as clsDatabase
    Set objDatabase = CreateObject("clsDatabase")

    Ofcourse, you can use the New keyword to create the object. However, this is
    safer because later you'll move to ActiveX DLL, you don't have to change
    it again.
    5. Once you are sure that everything is working, then you can copy the code
    of the clsDatabase to an ActiveXDLL. The reason is because debugging DLL is
    a harder than debugging your normal VB code.
    6. The ActiveX DLL can be installed on MTS machine, or on your machine.

    Good luck.
    TheBao

  5. #5

    Thread Starter
    Member
    Join Date
    May 2001
    Posts
    38

    Smile

    Thanks alot for the help I'll try that right away! (crossing fingers) If it works I'll be eternally grateful! (hehe)

    Cujo

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