|
-
Oct 30th, 2003, 10:10 AM
#1
Thread Starter
Lively Member
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.
-
Oct 30th, 2003, 07:22 PM
#2
Hyperactive Member
Make sure when you declare the Sub or Function you use the ByRef for the parameter that will be passing the connection.
VB Code:
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.
-
Oct 30th, 2003, 09:00 PM
#3
Thread Starter
Lively Member
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.
-
Oct 31st, 2003, 05:33 PM
#4
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|