Solved

COM component using VB 6

Posted on 2001-09-13
13
157 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
  • 4
  • 4
  • 2
  • +3
13 Comments
 
LVL 142

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 142

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
 
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Share codes 68 115
VBA Excel: fill / replace values based on a config sheet. 5 57
Vb.net 2008 2 51
Microsoft Access combo box help 2 30
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now