PDA

Click to See Complete Forum and Search --> : Another stupid ?


cujo3131
May 31st, 2001, 01:41 AM
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

TheBao
May 31st, 2001, 02:34 AM
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

cujo3131
May 31st, 2001, 06:24 PM
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

TheBao
May 31st, 2001, 07:48 PM
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

cujo3131
Jun 1st, 2001, 08:26 PM
Thanks alot for the help I'll try that right away! (crossing fingers) If it works I'll be eternally grateful! (hehe)

Cujo