Results 1 to 4 of 4

Thread: Dll Question[Resolved Thanks]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2002
    Posts
    90

    Dll Question[Resolved Thanks]

    I have an calling a procedure in a dll. The app creates an SQL connection to a database. Can I pass the Connection itself also to the procedure? I am trying to get away from having to go through the whole connection thing again on the dll. So in the class module of the dll can I have it say something like

    Public Sub PullRecords(sSQLCommand as string, sSQLConnection as SQLConnection)

    Also...
    What would be the best way of doing this. I have 2 private classes in the main public class of the dll. I am going to call a procedure in the public which will then call it one of the private classes depending on what is sent. This dll loads only when I open a new window in main app. for every window open i want it to launch a seperate instance of that dll. and then use the functions in the dll anytime needed as long as the window has not been close. Is that a good way of doing it or should I just have it call to the dll when ever needed and have the connection to the database created each time something is called on dll. (Which is why i asked the first question).

    Basically all the dll is doing is taking from one database and placing values into another one and vice versa.

    Thanks in advance.
    Last edited by OUSoonerFan; Oct 31st, 2003 at 10:54 PM.

  2. #2
    Hyperactive Member
    Join Date
    May 2002
    Location
    Wisconsin, USA
    Posts
    279
    Make sure when you declare the Sub or Function you use the ByRef for the parameter that will be passing the connection.

    VB Code:
    1. Public Sub PullRecords(ByRef sSQLConnection as SQLConnection)

    This will pass a reference to the Connection object to the sub or function.

    How scalable do you need this application to be? It is always better to create a dll that has all the database stuff in it. It is also much easier to maintain your code when you have a database layer (like a DLL) betweent the UI part of the application and the Database.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2002
    Posts
    90
    You hit it right on the money. I am wanting to basically create and establish the connection in main app..then in the dll perform an large database procedures that I need to do.. The small ones like logging in and etc I will do from main app. But the dll will basically be used to pull records everytime I run out on the main app. I just wanted to make sure that I can pass the connection object and not have to re-establish the connection again each time i use a sub or function in the dll.

    If i have this right please let me know and that will be another resolved issue i have from the nice people of vbforums.

  4. #4
    Hyperactive Member
    Join Date
    May 2002
    Location
    Wisconsin, USA
    Posts
    279
    Yes, like I said, by using ByRef when declaring the parameter that is used to pass the connection object to the procedure, it will actually pass a reference to the object. That means you will be able to edit/use the object just like it was created in that procedure. It will allow you to do what you want with the connection object.

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