如何使用具有通用数据库的企业库获取存储过程的参数 [英] How to get the parameters for a stored procedure using Enterprise library with generic database
本文介绍了如何使用具有通用数据库的企业库获取存储过程的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用它时,我得到以下异常
When i use this, i get the following exception
Parameter discovery is not supported for connections using GenericDatabase. You must specify the parameters explicitly, or configure the connection to use a type deriving from Database that supports parameter discovery.
除了这个程序还有其他正确的方法吗.
Is there a right way other than this procedure.
编辑
Database db = CustomDbFactory.CreateDataBase(connStrName);
DbCommand command = db.DbProviderFactory.CreateCommand();
command.CommandText = @spName;
command.CommandType = CommandType.StoredProcedure;
db.DiscoverParameters(command);
...
推荐答案
此功能仅支持 SqlDatabase
对象.因此,我没有在 GenericDatabase
上调用 DiscoverParameters
,而是从 SqlDatabase
调用它.具体问题.
This feature is supported only the SqlDatabase
objects only. Hence, instead of calling the DiscoverParameters
on a GenericDatabase
, I had to call it from a SqlDatabase
.. Specifics Issue.
这篇关于如何使用具有通用数据库的企业库获取存储过程的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文