enterprise-library-4.1

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 =

Return identity of last inserted row from stored procedure

微笑、不失礼 提交于 2019-12-01 08:27:30
I am trying to return identity of last inserted row from a stored procedure. A simplified version of my code looks like this: CREATE PROCEDURE [sp_name] @AuthorisationCode uniqueidentifier AS INSERT INTO [tablename] ([AuthorisationCode] ) VALUES (@AuthorisationCode ) RETURN @@IDENTITY GO I am calling this stored procedure via Execute Scalar in Enterprise library 4.1. It returns null. Anybody see what I am doing wrong. I'd say you should be using SCOPE_IDENTITY() as @@identity will return the identity of the last thing inserted (which may not be your stored procedure if multiple queries are

Return identity of last inserted row from stored procedure

China☆狼群 提交于 2019-12-01 04:48:18
问题 I am trying to return identity of last inserted row from a stored procedure. A simplified version of my code looks like this: CREATE PROCEDURE [sp_name] @AuthorisationCode uniqueidentifier AS INSERT INTO [tablename] ([AuthorisationCode] ) VALUES (@AuthorisationCode ) RETURN @@IDENTITY GO I am calling this stored procedure via Execute Scalar in Enterprise library 4.1. It returns null. Anybody see what I am doing wrong. 回答1: I'd say you should be using SCOPE_IDENTITY() as @@identity will return