Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Runtime 430 Error

Posted on 1999-09-28
18
Medium Priority
?
787 Views
Last Modified: 2013-12-25
Hi,

I have written an ActiveX dll which I have problems running
in a test client workstation.
I get the error;
{Runtime 430: CLASS DOES NOT SUPPORT AUTOMATION OR DOES NOT SUPPORT EXPECTED INTERFACE}

1) I had played around with the interfaces and methods in the course of testing this ActiveX dll in my PC.

2) When I was done, I switched the version compatiblity option under ProjectProperties/component tab to No compatibility option.
3) I compiled the dll, copied to the client PC,
unregistered the previous version and registered this version.

4) I wrote a sample vb client app to test it. When running
it, I got the error.

5) As easy as ActiveX dll was to write and test, deploying
it in other computers seems to be complicated. What am I
missing ?

ActiveX client sample code:
=================================
Private Sub Form_Load()
    test1
End Sub

Private Sub test1()
    Dim MySQL As PulseDbase.pDirectSQL
   
    Set MySQL = New PulseDbase.pDirectSQL
    MySQL.FieldSeperator = "|"
    MySQL.DbaseName = "metrics_tst"
   
    MySQL.DSN = "TAZ"
    MySQL.SQLString = "Select * from t_kandy"
    MySQL.RecordsReturnFlag = True
    MySQL.UserID = "sa"
    MySQL.ParameterTotal = 0
    MySQL.RequiredRowNumber = 2
    MySQL.Password = ""
    If MySQL.Execute <> 0 Then //ERROR HERE
        Debug.Print MySQL.ErrorString //ERROR STRING WITH RUNTIME 430 message
        Debug.Print MySQL.ActualSQL
    End If
   
    Debug.Print MySQL.RowTotal
    Debug.Print MySQL.ColumnTotal
    Debug.Print MySQL.RowInfo
   
    Set MySQL = Nothing
   
    Exit Sub
End Sub



=================================

ActiveX dll sample code:
==========================================
Option Explicit
'properties to be populated by client
Public DSN As String        'data source name
Public UserID As String     'user id for login
Public Password As String   'password for login
Public DbaseName As String  'database name
Public SQLString As String  'sql string to be executed
Public ParameterTotal As Integer 'number of parameters to be used by query
Public RecordsReturnFlag As Boolean  'Flag indicating if records are returned
Public RequiredRowNumber As Integer 'Required row of recordset
Public FieldSeperator As String  'seperator for fields returned

'properties to be populated by this ActiveX object
Public ColumnTotal As Integer   'Total number of columns from query
Public RowTotal As Integer      'Total number of records from query
Public RowInfo As String        'Contains single record information
Public ErrorString As String    'Contains error message if needed

'private properties
Private MySQLString As String
Private ParameterType(1 To 15) As String
Private ParameterValue(1 To 15) As String
Private MyConn As ADODB.Connection
Private MyCommand As ADODB.Command
Private MyRset As ADODB.Recordset
Private MyConnCleanupFlag As Boolean
Private MyRsetCleanupFlag As Boolean
Property Get ActualSQL()
    ActualSQL = MySQLString
End Property
Property Let ParmType(idx As Integer, val1 As String)
    If idx >= 0 And idx <= 15 Then
        ParameterType(idx) = val1
    End If
End Property
Property Let ParmValue(idx As Integer, val1 As String)
    If idx >= 0 And idx <= 15 Then
        ParameterValue(idx) = val1
    End If
End Property


Private Sub Class_Initialize()
    'Initialize properties to be populated by client
    DSN = ""
    UserID = ""
    Password = ""
    DbaseName = ""
    SQLString = ""
    RecordsReturnFlag = False
    RequiredRowNumber = 1
    ParameterTotal = -1
   
    'Initialize properties to be populated by this ActiveX object
    ColumnTotal = -1
    RowTotal = -1
    RowInfo = ""
    ErrorString = ""
    MySQLString = ""
    MyConnCleanupFlag = False
    MyRsetCleanupFlag = False
    Exit Sub
End Sub
Public Function Execute()
    On Error GoTo ErrorLabel
    ErrorString = "In Execute"
    If PrepareSQLString <> 0 Then
        GoTo ErrorLabel
    End If
   
    If (RecordsReturnFlag = False) Then
        If ExecuteSQLWithOutRecords <> 0 Then
            GoTo ErrorLabel
        End If
    Else
        If ExecuteSQLWithRecords <> 0 Then
            GoTo ErrorLabel
        End If
    End If
    Execute = 0
    GoTo ExitLabel
ErrorLabel:
    Execute = -1
ExitLabel:
    Exit Function
End Function

Private Function PrepareSQLString()
    'this function substitues the parameters in SQLString
    'as required
    Dim LoopIndex As Integer
    Dim CurrentLocation As Integer
    Dim NextLocation As Integer
    Dim ParmType As String
    Dim ParmValue As String
   
    On Error GoTo UnknownErrorLabel
    MySQLString = SQLString
   
    'check for parameters
    If ParameterTotal = 0 Then
        PrepareSQLString = 0
        GoTo ExitLabel
    ElseIf ParameterTotal < 0 Then
        PrepareSQLString = -1
        ErrorString = "Invalid property set by client: " & _
                     "ParameterTotal = <" & ParameterTotal & ">"
        GoTo ExitLabel
    End If
   
    CurrentLocation = 1
    NextLocation = 0
           
    'substitute parameters in order for each "?" found
    For LoopIndex = 1 To ParameterTotal
        If CurrentLocation > Len(SQLString) Then
            Exit For
        End If
        'check original string for next parameter
        NextLocation = InStr(CurrentLocation, SQLString, "?", vbTextCompare)
        'check if parameter symbol if found
        If NextLocation = 0 Then
            ErrorString = "Incorrect # of parameters specified"
            GoTo ErrorLabel
        End If
        If ParameterType(LoopIndex) = "TEXT" Then
            MySQLString = Replace(MySQLString, "?", "'" & ParameterValue(LoopIndex) & "'", 1, 1, vbTextCompare)
        Else
            MySQLString = Replace(MySQLString, "?", ParameterValue(LoopIndex), 1, 1, vbTextCompare)
        End If
        CurrentLocation = CurrentLocation + 1
        NextLocation = 0
    Next
   
    PrepareSQLString = 0
    GoTo ExitLabel

ErrorLabel:
    PrepareSQLString = -1
    GoTo ExitLabel

UnknownErrorLabel:
    ErrorString = "Error Number<" & Err.Number & _
        "> Error Description = <" & Err.Description & ">"
    PrepareSQLString = -1

ExitLabel:
    Exit Function
End Function
Private Function ExecuteSQLWithOutRecords()

    On Error GoTo ErrorLabel
    Dim ConnString As String
   
    Set MyConn = New ADODB.Connection
    MyConnCleanupFlag = True
    Set MyCommand = New ADODB.Command
   
    'formulate connection string
    ConnString = "DSN=" & DSN & ";uid=" & UserID & ";pwd=" & _
                Password & ";database=" & DbaseName
    MyConn.Open (ConnString)
    MyCommand.ActiveConnection = MyConn
    MyCommand.CommandText = MySQLString
    MyCommand.Execute
   
    ExecuteSQLWithOutRecords = 0
    GoTo ExitLabel
ErrorLabel:
    ErrorString = "Error Number<" & Err.Number & _
        "> Error Description = <" & Err.Description & ">"
    ExecuteSQLWithOutRecords = -1
ExitLabel:
    Exit Function
End Function

Private Function ExecuteSQLWithRecords()

    On Error GoTo UnknownErrorLabel
   
    Dim LoopIndex As Integer
    Dim ConnString As String
    Set MyConn = New ADODB.Connection
    Set MyRset = New ADODB.Recordset
   
    MyConnCleanupFlag = True
    MyRsetCleanupFlag = True
    'formulate connection string
    ConnString = "DSN=" & DSN & ";uid=" & UserID & ";pwd=" & _
                Password & ";database=" & DbaseName
    MyConn.Open (ConnString)
    MyRset.Open MySQLString, MyConn, adOpenStatic, adLockReadOnly, adCmdText

    'populate record count and record info
    If MyRset.BOF And MyRset.EOF Then
        RowTotal = 0
    Else
        RowTotal = MyRset.RecordCount
        ErrorString = "After columntotal"
        ColumnTotal = MyRset.Fields.Count
        'move to required row number
        If RequiredRowNumber > 0 Then
            MyRset.Move RequiredRowNumber - 1
            If MyRset.BOF Or MyRset.EOF Then
                ErrorString = "RequiredRowNumber <" & RequiredRowNumber & "> not valid"
                GoTo ErrorLabel
            End If
        End If
        For LoopIndex = 0 To MyRset.Fields.Count - 1
            If LoopIndex = 0 Then
                RowInfo = MyRset.Fields.Item(LoopIndex)
            Else
                RowInfo = RowInfo & FieldSeperator & MyRset.Fields.Item(LoopIndex)
            End If
        Next LoopIndex
    End If
   
    ExecuteSQLWithRecords = 0
    GoTo ExitLabel
UnknownErrorLabel:
    ErrorString = "Error Number<" & Err.Number & _
        "> Error Description = <" & Err.Description & ">"
ErrorLabel:
    ExecuteSQLWithRecords = -1
ExitLabel:
    Exit Function
End Function

Private Sub Class_Terminate()
    'close connection if open
    If MyConnCleanupFlag = True Then
        If MyConn.State = adStateOpen Then
            MyConn.Close
        End If
    End If
   
    'close recordset if open
    If MyRsetCleanupFlag = True Then
        If MyRset.State = adStateOpen Then
            MyRset.Close
        End If
    End If
End Sub
==========================

I need this to work. Appreciate all the help.

Thanks
0
Comment
Question by:kkandasa
[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
  • 5
  • 4
  • 2
  • +6
18 Comments
 
LVL 4

Expert Comment

by:P1
ID: 2082932
Maybe you should cross post to VB Controls, because the problem is not the DB access, but in your Control Object.
0
 
LVL 5

Expert Comment

by:AnswerTheMan
ID: 2082951
from a really quick look at it , it seems that MyCONN is being SET NEW and OPENED 2 times without closing it an SET it to NOTHING in between.
Private Function ExecuteSQLWithRecords()  AND
Private Function ExecuteSQLWithOutRecords() ARE activate each after the other and each one Initializing MyCONN and opens it without closing and destructing in between.
BUT in this case i almost sure that the error msg should be other from the one you get.

   

   
0
 
LVL 8

Expert Comment

by:vettranger
ID: 2082961
According to the following article, you may need to be using binary compatibility. Have you seen this one?

http://support.microsoft.com/support/kb/articles/Q190/1/31.ASP


Also look at :

http://support.microsoft.com/support/kb/articles/Q193/1/72.ASP

This doesn't seem as on topic for your situation, but I've learned that any little bit of information can sometimes help!
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 5

Expert Comment

by:AnswerTheMan
ID: 2082989
hey, now that i've read your other question i get it.
your dll is initialized and terminate just before you can say Jack Robinson, BECAUSE that's the way you wrote it.
when you call the EXECUTE function from your client the dll is already GONE and OFF.
put in it INITAILIZE method some invisible FORM to keep the DLL ALIVE  - so your client will have it avail;able.
0
 

Author Comment

by:kkandasa
ID: 2084988
Hi,
Thank you for the response. I do have some questions.
I read up on "Visual Basic Component shutdown rules" for
an in-process component.

Rules for shutdown:

1) There are no references - internal or external - to
the component's public objects.
In my client sample code, I thought the following statement
ensures reference.
--------
    Dim MySQL As PulseDbase.pDirectSQL
    Set MySQL = New PulseDbase.pDirectSQL
--------

2) The component has no forms visible.
I have no forms in my case. You suggested invisible forms. Does that work?

I will try these out. Any comments you have would be
great.

Shouldn't
0
 
LVL 2

Expert Comment

by:ferkel
ID: 2085055
I think you're right kkandasa, as long as there are references the component
will not unload. And there is a reference as long as your MySQL variable is
valid.

Your code ran without errors on my machine with VB6(SP3). Which VB Version
do you use?

One thing you could try out is the following:
Specify the return type of method execute as:
Public Function Execute() As Boolean
or as
Public Function Execute() As Long

your current Execute returns a variant. Maybe this will help.

0
 
LVL 15

Expert Comment

by:ameba
ID: 2085775
>deploying it in other computers seems to be complicated.
If you have many 'trial' instalations, you use trick with CreateObject. See article:
Binary compatibility issues in Visual Basic (Francesco Balena)
http://www.comdeveloper.com/articles/binarycomp.asp
0
 

Expert Comment

by:bubus
ID: 2087399
I notice you ar using DSNs. Did you create them on the Client Computer?
0
 

Expert Comment

by:dvlasman
ID: 2088151

I would set the ActiveX dll to binary compatability.
You did not mention if you re-compiled the test program after you compiled the ActiveX dll. With No Compatibility set, a new object ID is generated every time you compile the ActiveX dll. If the test application is not recompiled, the app will be looking for the old object ID that will no longer exist in the registry.

0
 

Author Comment

by:kkandasa
ID: 2088379
I had to create a package and deploy it. The client
computer did not have SP3 for vb6.

Thanks.
0
 

Expert Comment

by:bubus
ID: 2088403
I understand that for you to use DSNs they need to be created on the system that is using them to make Data Connections.
0
 
LVL 2

Expert Comment

by:ferkel
ID: 2088458
Are your problems solved now?
0
 

Author Comment

by:kkandasa
ID: 2088548
Yes, the client did not have sp3 for vb6. I created a
package via the package and deployment wizard. It works
now.

Thanks
0
 
LVL 2

Expert Comment

by:ferkel
ID: 2088662
For this was definitely not a 600 pts question i think it would not be fair to
send an answer. I suggest you ask customer service to delete it.

ask another question with a score you think that is adequate and i'll tell you
another minor bug in your dll code.

0
 

Author Comment

by:kkandasa
ID: 2088685
Hi Ferkel,
Points is not a problem. I spent over two days
on this problem. Answer this question with the dll
bug you found and I will accept the answer and credit
you with the points.

Thanks.
0
 
LVL 2

Accepted Solution

by:
ferkel earned 2400 total points
ID: 2088724
Thanks, kkandasa
the other bug i saw is in the range checking of the
ParamType- and ParamValue-Properties.
You should correct it to be
  If idx >= 1 And idx <= 15 Then ....



0
 

Author Comment

by:kkandasa
ID: 2088751
Thanks
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6823502
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.

This is the Community Support link, if help is needed, along with the link to All Topics since many new ones were recently added.

http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
http://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thanks,
Moondancer
Moderator @ Experts Exchange
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.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

670 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