Solved

COM component using VB 6

Posted on 2001-09-13
13
162 Views
Last Modified: 2010-05-02
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
Comment
Question by:renjith
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
  • +3
13 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6479018
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
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6479020
On the other hand, your DLL might not be build as binary compatible...
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6479023
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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 1

Author Comment

by:renjith
ID: 6479068
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
 
LVL 22

Expert Comment

by:CJ_S
ID: 6479100
I do not think the component is registered. Either that or you are using the wrong name.
0
 
LVL 1

Author Comment

by:renjith
ID: 6479596
How else can I confirm that the component is registered ?
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6479634
go to Run -> regedit

search for "DBdata.getData"

Regards,
CJ
0
 
LVL 1

Author Comment

by:renjith
ID: 6481714
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
 
LVL 22

Expert Comment

by:CJ_S
ID: 6481758
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
 
LVL 1

Author Comment

by:renjith
ID: 6482407
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
 
LVL 10

Expert Comment

by:GoodJun
ID: 6488481
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 7208350
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
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 7241179
Per recommendation, points refunded and question closed.

Netminder
CS Moderator
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question