我有一个由传统ASP页面使用的.NET程序集.我创建了一个返回ADODB记录集的方法.在我的ADODB命令对象中,我使用以下格式向adCmdstoredProc CommandType属性提供参数…
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
System.Exception was unhandled
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.
在线:
.Parameters.Append(.CreateParameter("@book",MyBook))
有任何想法吗?
存储过程:
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
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。