Note that there are some explanatory texts on larger screens.

plurals
  1. POError when adding parameters to ADODB command in a .NET assembly
    primarykey
    data
    text
    <p>I have a .NET assembly that is being consumed by a classic ASP page. I've created a method that returns a ADODB recordset. In my ADODB command object I'm supplying parameters using the following format to a adCmdStoredProc CommandType property...</p> <pre><code>With ADODBCmd .ActiveConnection = ADODBConn .Prepared = True .CommandType = CommandTypeEnum.adCmdStoredProc .NamedParameters = True .CommandText = Sql_GetMyBook .Parameters.Append(.CreateParameter("@book", DataTypeEnum.adChar, ParameterDirectionEnum.adParamInput, 50, MyBook)) End With </code></pre> <p>I get a casting error ...</p> <blockquote> <p>System.Exception was unhandled<br> Message=System.InvalidCastException: 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 components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.</p> </blockquote> <p>at line:</p> <pre><code>.Parameters.Append(.CreateParameter("@book", DataTypeEnum.adChar, ParameterDirectionEnum.adParamInput, 50, MyBook)) </code></pre> <p>Any ideas?</p> <p>Stored Proc:</p> <pre><code>ALTER PROCEDURE [dbo].[GetMybook] -- Add the parameters for the stored procedure here @book char(50) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here SELECT BookTitle, Author, PulishedDate FROM Library WHERE BookTitle=@book </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload