Link to home
Start Free TrialLog in
Avatar of renjith
renjith

asked on

COM component using VB 6

I've created a COM component(DBdata.dll) using VB6. This component returns a recordset when provided with a sql query.
But when I use it from a form it is giving the error - "Run-time error '429' ActiveX component cannot create object". what could be the reason ?
I have both form and class file in the same project.
I've added the 'References'
1. Microsoft ActiveX DataObjects 2.1 library
2. Microsoft ActiveX DataObjects Recordset 2.1 library
--------------------------------------------------------
Following is the code for the class file(getData.cls).

Public Function RS_result(ByVal strSQL As String) As ADODB.Recordset

Dim ad As ADODB.Connection
Dim ar As ADODB.Recordset

Set ad = New ADODB.Connection
Set ar = New ADODB.Recordset

Let ad.ConnectionString="provider=SQLOLEDB;data source=pdc;uid=starwar2001;pwd=captaincook;database=intranet"
ad.Open
ar.Open strSQL, ad

Set RS_result = ar

End Function
---------------------------------------------------------

Following is the code for the form (DataAccess.frm)

Private Sub Form_Load()
Set db  = CreateObject("DBdata.getData")
Data_result = db.RS_result("select firstname from M_EmployeeDetail Where empid=100")

Msgbox Data_result

End Sub

---------------------------------------------------------

But when i have the code in getData.cls in a .frm its working fine.

Hoping for a solution :)
regards
renjith
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Open the .frm file once in an normal editor, like notepad.
Check if there are any references to older MDAC (ADO2.0, or even ADO1.x)...
Normally, all the references are in the .vbp file, but it happens that VB puts some of them to the .frm file...

Cheers
On the other hand, your DLL might not be build as binary compatible...
2 options

- The component Dbdata.getData should be compiled and registered on the machine.
- you can have a project group in which you have both the application-project and the activex dll project. You can then set a reference to the activex dll by setting it in the application-project.

Regards,
CJ
Avatar of renjith
renjith

ASKER

I feel it has something to do with the Component and nothing to do with compilation and registration. Bocz the other components created in the same machine are working fine. But those components were not dealing with database and recordsets. Is there any other reference i've to make other than the above mentioned ones ?
I tried to use this component using ASP too, there its giving the error "wrong ProgID".
I do not think the component is registered. Either that or you are using the wrong name.
Avatar of renjith

ASKER

How else can I confirm that the component is registered ?
go to Run -> regedit

search for "DBdata.getData"

Regards,
CJ
Avatar of renjith

ASKER

The component is not getting registered. Though after registering it gives confirmation as registration  successful, its not present in the Registry Editor. What could be the reason ?
Your registry  might not update or visible changes. What you can do is place the .dll file in the same directory as the other executable.
Avatar of renjith

ASKER

I've tried placing the .dll file in the same
directory as the other executable still its not working.
Angell, what do u mean by "your DLL might not be build as binary compatible" ?
separage your form from the class in different project.
you can't use Set db  = CreateObject("DBdata.getData") while they are in the same project.

you can use set db= new getdata if you keep them in the same project. (but when move to asp, you will need to separate them anyway.



Hi renjith,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

renjith, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
ASKER CERTIFIED SOLUTION
Avatar of Netminder
Netminder

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial