|
|
Question : Enterprise library insert the following.
|
|
Given the following insert set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go
CREATE PROCEDURE [dbo].[sprInsertIntoTickets] ( @ticketNumber AS nvarchar(50) = null, @ticketType AS nvarchar(50) = null, @ticketStatus AS nvarchar(50) = null, @ticketSeverity AS nvarchar(50) = null, @shortDescription AS nvarchar(1000) = null, @externalTicket AS nvarchar(1000) = null, @reasonMenu AS nvarchar(50) = null, @problemNote AS ntext = null, @solutionNote AS ntext = null, @actionNote AS ntext = null, @followupNote AS ntext = null, @companiesFlag AS bit = null, @agentCreated AS nvarchar(50) = null, @dateCreated AS datetime = null, @dateLastModified AS datetime = null, @agentClosed AS nvarchar(50) = null, @dateClosed AS datetime = null, @agentFollowup AS nvarchar(50) = null, @followupBy AS datetime = null, @deletedFlag AS bit = null, @ticketTypeOld AS nvarchar(50) = null, @assignedTo AS varchar(50) = null, @requestType AS varchar(50) = null, @serviceImpact AS varchar(50) = null, @dateTimeAssigned AS datetime = null, @priority AS varchar(50) = null, @dateAssigned AS datetime = null, @trackIt AS varchar(50) = null, @contactMethod AS varchar(50) = null, @locationSIMs AS varchar(50) = null, @userID AS nvarchar(50) = null, @ticketApplicationType AS nvarchar(50) = null, @accountID AS int = null ) AS
INSERT INTO [dbo].[tbl_tickets] ( [TicketNumber], [TicketType], [TicketStatus], [TicketSeverity], [ShortDescription], [ExternalTicket], [ReasonMenu], [ProblemNote], [SolutionNote], [ActionNote], [FollowupNote], [CompaniesFlag], [AgentCreated], [DateCreated], [DateLastModified], [AgentClosed], [DateClosed], [AgentFollowup], [FollowupBy], [DeletedFlag], [TicketTypeOld], [AssignedTo], [RequestType], [ServiceImpact], [DateTimeAssigned], [Priority], [DateAssigned], [TrackIt], [ContactMethod], [LocationSIMs], [UserID], [TicketApplicationType], [AccountID] ) VALUES ( @ticketNumber, @ticketType, @ticketStatus, @ticketSeverity, @shortDescription, @externalTicket, @reasonMenu, @problemNote, @solutionNote, @actionNote, @followupNote, @companiesFlag, @agentCreated, @dateCreated, @dateLastModified, @agentClosed, @dateClosed, @agentFollowup, @followupBy, @deletedFlag, @ticketTypeOld, @assignedTo, @requestType, @serviceImpact, @dateTimeAssigned, @priority, @dateAssigned, @trackIt, @contactMethod, @locationSIMs, @userID, @ticketApplicationType, @accountID )
SELECT SCOPE_IDENTITY() ============================================================
public static int InsertIntoTickets() { Database db = DatabaseFactory.CreateDatabase(); DbCommand dc = db.GetStoredProcCommand("sprInsertIntoTickets"); how can I sett this parameters in Enterprise Library. db.AddInParameter(dc, "intNodeId", DbType.Int32, 7553); db.AddInParameter(dc, "intAuditId", DbType.Int32, 5001); db.AddInParameter(dc, "strDesc", DbType.String, "fssfsdf"); db.AddOutParameter(dc, "result", DbType.Int32, 100);
db.ExecuteNonQuery(dc); return Convert.ToInt32(db.GetParameterValue(dc, "result")); }
|
Answer : Enterprise library insert the following.
|
|
You cannot use the ExecuteNonQuery method in order to return the resultset containing the SCOPE_IDENTITY(). You either need to return it as an OUTPUT parameter or change the method to ExecuteReader.
|
|
|
|
|