Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

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
0
renjith
Asked:
renjith
  • 4
  • 4
  • 2
  • +3
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
On the other hand, your DLL might not be build as binary compatible...
0
 
CJ_SCommented:
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
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
renjithAuthor Commented:
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".
0
 
CJ_SCommented:
I do not think the component is registered. Either that or you are using the wrong name.
0
 
renjithAuthor Commented:
How else can I confirm that the component is registered ?
0
 
CJ_SCommented:
go to Run -> regedit

search for "DBdata.getData"

Regards,
CJ
0
 
renjithAuthor Commented:
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 ?
0
 
CJ_SCommented:
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.
0
 
renjithAuthor Commented:
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" ?
0
 
GoodJunCommented:
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.



0
 
DanRollinsCommented:
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
0
 
NetminderCommented:
Per recommendation, points refunded and question closed.

Netminder
CS Moderator
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 4
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now