How to get the parameters for a stored procedure using Enterprise library with generic database

偶尔善良 提交于 2019-12-08 09:54:36

问题


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.

EDIT

Database db = CustomDbFactory.CreateDataBase(connStrName); 
DbCommand command = db.DbProviderFactory.CreateCommand(); 
command.CommandText = @spName; 
command.CommandType = CommandType.StoredProcedure; 
db.DiscoverParameters(command); 
...

回答1:


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.



来源:https://stackoverflow.com/questions/8590524/how-to-get-the-parameters-for-a-stored-procedure-using-enterprise-library-with-g

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!