Solved

Unable to cast COM object of type 'System.__ComObject' to class type 'ADODB.InternalParameter'. Instances of types that represent COM components cannot be cast to types that do not represent COM compo

Posted on 2011-09-08
6
1,359 Views
Last Modified: 2012-06-22
I am using ADODB to run a sql strored procedure in VB.Net.

when my code gets to the line

cmd.Parameters.Append(cmd.CreateParameter("CampaignName", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 50, "Annuities"))

I get the error in the title.

Can anybody suggest wy?
sqlstr = "SELECT * FROM WebEnquiries WHERE WebEnquiryID = '" & WebEnquiryID & "'"
        rs.Open(sqlstr, sqlCnn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)

        If rs.RecordCount = 0 Then
            rs.Close()
            Exit Function
        End If


        Dim cmd As New ADODB.Command
        Dim cnn As New ADODB.Connection

        cnn.ConnectionString = sqlDialler
        cnn.Open()

        cmd.ActiveConnection = cnn
        cmd.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc
        cmd.CommandText = "InsertCampaignRecord"

        cmd.Parameters.Append(cmd.CreateParameter("CampaignName", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 50, "Annuities"))
        cmd.Parameters.Append(cmd.CreateParameter("Tel1", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 20, rs.Fields("daytime_telephone").Value))

Open in new window

0
Comment
Question by:ict-torquilclark
[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
  • 3
  • 2
6 Comments
 
LVL 4

Expert Comment

by:thewild
ID: 36501391
I believe the parenthesis are confusing Access.
Could you try :
cmd.Parameters.Append cmd.CreateParameter("CampaignName", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 50, "Annuities")

Open in new window

0
 
LVL 1

Author Comment

by:ict-torquilclark
ID: 36501420
I have tried that but visual studio just puts them back in.
0
 
LVL 4

Expert Comment

by:thewild
ID: 36501442
Really ? That's weird.
Maybe you should "call" the method then ?

Call cmd.Parameters.Append(cmd.CreateParameter("CampaignName", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 50, "Annuities"))

Open in new window

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!

 
LVL 1

Author Comment

by:ict-torquilclark
ID: 36503188
nope that daoes work either :(
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36506255
You may have been asked many times before but do you HAVE to use ADODB in VB.NET?
0
 
LVL 4

Accepted Solution

by:
thewild earned 500 total points
ID: 36508393
There might be a problem with the ADO library you are referencing.
Wich version number is it ?
Can you try with another one (lower or higher version number) ?
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

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 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…

726 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