Solved

Input string was not in a correct format.

Posted on 2009-05-19
5
525 Views
Last Modified: 2012-05-07
Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:


Line 179:
Line 180:
Line 181:            res.Code = Int32.Parse(cmd.Parameters["@resultCode"].ToString());
Line 182:            res.Message = cmd.Parameters["@resultMessage"].ToString();
Line 183:
 

[DataObjectMethod(DataObjectMethodType.Update, true)]
        public static TransactionResult UpdateReOpenedTicket(Ticket ticket)
        {
            TransactionResult res = new TransactionResult();

            Database db = DatabaseFactory.CreateDatabase();
            string sql = "sprUpdateReOpenedTicket";
            DbCommand cmd = db.GetStoredProcCommand(sql);
            db.AddInParameter(cmd, "@ticketID", DbType.Int32, ticket.TicketID);
            db.AddInParameter(cmd, "@ticketNumber", DbType.String, ticket.TicketNumber);
            db.AddInParameter(cmd, "@ticketType", DbType.String, ticket.TicketType);
            db.AddInParameter(cmd, "@ticketStatus", DbType.String, ticket.TicketStatus);
            db.AddInParameter(cmd, "@ticketSeverity", DbType.String, ticket.TicketSeverity);
            db.AddInParameter(cmd, "@shortDescription", DbType.String, ticket.ShortDescription);
            db.AddInParameter(cmd, "@externalTicket", DbType.String, ticket.ExternalTicket);
            db.AddInParameter(cmd, "@reasonMenu", DbType.String, ticket.ReasonMenu);
            db.AddInParameter(cmd, "@problemNote", DbType.String, ticket.ProblemNote);
            db.AddInParameter(cmd, "@solutionNote", DbType.String, ticket.SolutionNote);
            db.AddInParameter(cmd, "@actionNote", DbType.String, ticket.ActionNote);
            db.AddInParameter(cmd, "@followupNote", DbType.String, ticket.FollowupNote);
            db.AddInParameter(cmd, "@companiesFlag", DbType.Boolean, ticket.CompaniesFlag);
            db.AddInParameter(cmd, "@agentCreated", DbType.String, ticket.AgentCreated);
            db.AddInParameter(cmd, "@dateCreated", DbType.DateTime, ticket.DateCreated);
            db.AddInParameter(cmd, "@dateLastModified", DbType.DateTime, ticket.DateLastModified);
            db.AddInParameter(cmd, "@agentClosed", DbType.String, ticket.AgentClosed);
            db.AddInParameter(cmd, "@dateClosed", DbType.DateTime, ticket.DateClosed);
            db.AddInParameter(cmd, "@agentFollowup", DbType.String, ticket.AgentFollowup);
            db.AddInParameter(cmd, "@followupBy", DbType.DateTime, ticket.FollowupBy);
            db.AddInParameter(cmd, "@deletedFlag", DbType.Boolean, ticket.DeletedFlag);
            db.AddInParameter(cmd, "@ticketTypeOld", DbType.String, ticket.TicketTypeOld);
            db.AddInParameter(cmd, "@assignedTo", DbType.String, ticket.AssignedTo);
            db.AddInParameter(cmd, "@requestType", DbType.String, ticket.RequestType);
            db.AddInParameter(cmd, "@serviceImpact", DbType.String, ticket.ServiceImpact);
            db.AddInParameter(cmd, "@dateTimeAssigned", DbType.DateTime, ticket.DateTimeAssigned);
            db.AddInParameter(cmd, "@priority", DbType.String, ticket.Priority);
            db.AddInParameter(cmd, "@dateAssigned", DbType.DateTime, ticket.DateTimeAssigned);
            db.AddInParameter(cmd, "@trackIt", DbType.String, ticket.TrackIt);
            db.AddInParameter(cmd, "@contactMethod", DbType.String, ticket.ContactMethod);
            db.AddInParameter(cmd, "@locationSIMs", DbType.String, ticket.LocationSIMs);
            db.AddInParameter(cmd, "@userID", DbType.String, ticket.UserID);
            db.AddInParameter(cmd, "@ticketApplicationType", DbType.String, ticket.TicketApplicationType);
            db.AddInParameter(cmd, "@accountID", DbType.Int32, ticket.AccountID);

            db.AddOutParameter(cmd, "@resultCode", DbType.Int32, 4);
            db.AddOutParameter(cmd, "@resultMessage", DbType.String, 200);

            db.ExecuteNonQuery(cmd);


            res.Code = Int32.Parse(cmd.Parameters["@resultCode"].ToString());
            res.Message = cmd.Parameters["@resultMessage"].ToString();


            return res;
        }

        [DataObjectMethod(DataObjectMethodType.Update, true)]
        public static TransactionResult UpdateClosedTicket(Ticket ticket)
        {
            TransactionResult res = new TransactionResult();

            Database db = DatabaseFactory.CreateDatabase();
            string sql = "sprUpdateClosedTicket";
            DbCommand cmd = db.GetStoredProcCommand(sql);
            db.AddInParameter(cmd, "@ticketID", DbType.Int32, ticket.TicketID);
            db.AddInParameter(cmd, "@ticketNumber", DbType.String, ticket.TicketNumber);
            db.AddInParameter(cmd, "@ticketType", DbType.String, ticket.TicketType);
            db.AddInParameter(cmd, "@ticketStatus", DbType.String, ticket.TicketStatus);
            db.AddInParameter(cmd, "@ticketSeverity", DbType.String, ticket.TicketSeverity);
            db.AddInParameter(cmd, "@shortDescription", DbType.String, ticket.ShortDescription);
            db.AddInParameter(cmd, "@externalTicket", DbType.String, ticket.ExternalTicket);
            db.AddInParameter(cmd, "@reasonMenu", DbType.String, ticket.ReasonMenu);
            db.AddInParameter(cmd, "@problemNote", DbType.String, ticket.ProblemNote);
            db.AddInParameter(cmd, "@solutionNote", DbType.String, ticket.SolutionNote);
            db.AddInParameter(cmd, "@actionNote", DbType.String, ticket.ActionNote);
            db.AddInParameter(cmd, "@followupNote", DbType.String, ticket.FollowupNote);
            db.AddInParameter(cmd, "@companiesFlag", DbType.Boolean, ticket.CompaniesFlag);
            db.AddInParameter(cmd, "@agentCreated", DbType.String, ticket.AgentCreated);
            db.AddInParameter(cmd, "@dateCreated", DbType.DateTime, ticket.DateCreated);
            db.AddInParameter(cmd, "@dateLastModified", DbType.DateTime, ticket.DateLastModified);
            db.AddInParameter(cmd, "@agentClosed", DbType.String, ticket.AgentClosed);
            db.AddInParameter(cmd, "@dateClosed", DbType.DateTime, ticket.DateClosed);
            db.AddInParameter(cmd, "@agentFollowup", DbType.String, ticket.AgentFollowup);
            db.AddInParameter(cmd, "@followupBy", DbType.DateTime, ticket.FollowupBy);
            db.AddInParameter(cmd, "@deletedFlag", DbType.Boolean, ticket.DeletedFlag);
            db.AddInParameter(cmd, "@ticketTypeOld", DbType.String, ticket.TicketTypeOld);
            db.AddInParameter(cmd, "@assignedTo", DbType.String, ticket.AssignedTo);
            db.AddInParameter(cmd, "@requestType", DbType.String, ticket.RequestType);
            db.AddInParameter(cmd, "@serviceImpact", DbType.String, ticket.ServiceImpact);
            db.AddInParameter(cmd, "@dateTimeAssigned", DbType.DateTime, ticket.DateTimeAssigned);
            db.AddInParameter(cmd, "@priority", DbType.String, ticket.Priority);
            db.AddInParameter(cmd, "@dateAssigned", DbType.DateTime, ticket.DateTimeAssigned);
            db.AddInParameter(cmd, "@trackIt", DbType.String, ticket.TrackIt);
            db.AddInParameter(cmd, "@contactMethod", DbType.String, ticket.ContactMethod);
            db.AddInParameter(cmd, "@locationSIMs", DbType.String, ticket.LocationSIMs);
            db.AddInParameter(cmd, "@userID", DbType.String, ticket.UserID);
            db.AddInParameter(cmd, "@ticketApplicationType", DbType.String, ticket.TicketApplicationType);
            db.AddInParameter(cmd, "@accountID", DbType.Int32, ticket.AccountID);

            db.AddOutParameter(cmd, "@resultCode", DbType.Int32, 4);
            db.AddOutParameter(cmd, "@resultMessage", DbType.String, 200);

            db.ExecuteNonQuery(cmd);


            res.Code = Int32.Parse(cmd.Parameters["@resultCode"].ToString());
            res.Message = cmd.Parameters["@resultMessage"].ToString();


            return res;
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].sprUpdateReOpenedTicket') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].sprUpdateReOpenedTicket
GO
 
CREATE PROCEDURE [dbo].sprUpdateReOpenedTicket
(
@ticketID int = null,
@ticketNumber nvarchar(50) = null,
@ticketType nvarchar(50) = null,
@ticketStatus nvarchar(50) = null,
@ticketSeverity nvarchar(50) = null,
@shortDescription nvarchar(1000) = null,
@externalTicket nvarchar(1000) = null,
@reasonMenu nvarchar(50) = null,
@problemNote ntext = null,
@solutionNote ntext = null,
@actionNote ntext = null,
@followupNote ntext = null,
@companiesFlag bit = null,
@agentCreated nvarchar(50) = null,
@dateCreated datetime = null,
@dateLastModified datetime = null,
@agentClosed nvarchar(50) = null,
@dateClosed datetime = null,
@agentFollowup nvarchar(50) = null,
@followupBy datetime = null,
@deletedFlag bit = null,
@ticketTypeOld nvarchar(50) = null,
@assignedTo varchar(50) = null,
@requestType varchar(50) = null,
@serviceImpact varchar(50) = null,
@dateTimeAssigned datetime = null,
@priority varchar(50) = null,
@dateAssigned datetime = null,
@trackIt varchar(50) = null,
@contactMethod varchar(50) = null,
@locationSIMs varchar(50) = null,
@userID nvarchar(50) = null,
@ticketApplicationType nvarchar(50) = null,
@accountID int = null,
@resultCode INT OUTPUT,
@resultMessage NVARCHAR(200) OUTPUT
)
AS
 
BEGIN
      BEGIN TRANSACTION
      BEGIN TRY
UPDATE
  [dbo].[tbl_tickets]
SET
  [TicketNumber] = @ticketNumber,
  [TicketType] = @ticketType,
  [TicketStatus] = @ticketStatus,
  [TicketSeverity] = @ticketSeverity,
  [ShortDescription] = @shortDescription,
  [ExternalTicket] = @externalTicket,
  [ReasonMenu] = @reasonMenu,
  [ProblemNote] = @problemNote,
  [SolutionNote] = @solutionNote,
  [ActionNote] = @actionNote,
  [FollowupNote] = @followupNote,
  [CompaniesFlag] = @companiesFlag,
  [AgentCreated] = @agentCreated,
  [DateCreated] = @dateCreated,
  [DateLastModified] = @dateLastModified,
  [AgentClosed] = @agentClosed,
  [DateClosed] = @dateClosed,
  [AgentFollowup] = @agentFollowup,
  [FollowupBy] = @followupBy,
  [DeletedFlag] = @deletedFlag,
  [TicketTypeOld] = @ticketTypeOld,
  [AssignedTo] = @assignedTo,
  [RequestType] = @requestType,
  [ServiceImpact] = @serviceImpact,
  [DateTimeAssigned] = @dateTimeAssigned,
  [Priority] = @priority,
  [DateAssigned] = @dateAssigned,
  [TrackIt] = @trackIt,
  [ContactMethod] = @contactMethod,
  [LocationSIMs] = @locationSIMs,
  [UserID] = @userID,
  [TicketApplicationType] = @ticketApplicationType,
  [AccountID] = @accountID
WHERE
  [TicketID] = @ticketID
              
              
              SET @resultCode = 0
              SET @resultMessage = 'ticketID ' + CAST(@ticketID  AS NVARCHAR(200)) + ': ' + @ticketNumber  + ' was updated.'
              
   
        END TRY
   
        BEGIN CATCH
  	IF @@TRANCOUNT > 1 ROLLBACK
              
              SET @ticketID = 0
              SET @resultCode = 1
              SET @resultMessage = 'ticketID ' + CAST(@ticketID AS NVARCHAR(200)) + ': ' + @ticketNumber + ' update error.  ' + char(13) + char(10)
                          + ERROR_NUMBER() + '. '  + char(13) + char(10)
                          + ERROR_MESSAGE() + '. ' + char(13) + char(10)
                          + ERROR_LINE() + '. ' + char(13) + char(10)
                          + ERROR_PROCEDURE() + '. ' + char(13) + char(10)
                          + ERROR_STATE() + '. ' + char(13) + char(10)
   
        END CATCH
  
  COMMIT TRAN
  END
GO

Open in new window

0
Comment
Question by:mathieu_cupryk
  • 3
  • 2
5 Comments
 
LVL 11

Expert Comment

by:Muhammad Ousama Ghazali
ID: 24425023
Replace this
res.Code = Int32.Parse(cmd.Parameters["@resultCode"].ToString());

with this
res.Code = cmd.Parameters["@resultCode"];
0
 

Author Comment

by:mathieu_cupryk
ID: 24425336
Error      7      Cannot implicitly convert type 'System.Data.Common.DbParameter' to 'int'      C:\svn\2009_0514_MC_1_0_a\code\KORE.SIDWebClient.DAL\DAL\Tickets\TicketData.cs      180      24      KORE.SIDWebClient.DAL
0
 
LVL 11

Accepted Solution

by:
Muhammad Ousama Ghazali earned 500 total points
ID: 24425753
Sorry, forgot it is C# and not VB.
Use this instead:
res.Code = Int32.Parse(cmd.Parameters["@resultCode"]);
0
 

Author Closing Comment

by:mathieu_cupryk
ID: 31597512
db.AddOutParameter(cmd, "@resultCode", DbType.Int32, 4);
            db.AddOutParameter(cmd, "@resultMessage", DbType.String, 200);

            db.ExecuteNonQuery(cmd);

            res.Code = (Int32)cmd.Parameters["@resultCode"].Value;
            res.Message = cmd.Parameters["@resultMessage"].ToString();


            return res;
0
 
LVL 11

Expert Comment

by:Muhammad Ousama Ghazali
ID: 24428758
Thank you for correcting me too.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
When should I use a controller? 3 34
Open MVC5 View in new Window (not Tab) using HTML.ActionLink 6 28
ASP.NET MVC 2 31
Deploying to Azure 3 28
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question