Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input string was not in a correct format

Status
Not open for further replies.

niall29

Technical User
May 1, 2003
38
GB
I am using the update feature in a gridview in ASP.NET 2005

I am passing parameters to a Stored procedure which seems to work, but when the page is loading up again I get the error
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.

If I close the page and reopen it, it has the new values so it did update.



I think my problem might be coming from my DDL and my stored procedure because when I tried to make the value of my ddl Type_ID it crashed everytime so I had to make the text = Type_Name and the value Type_Name then I got the ID in my stored procedure.

So I am including my Stored procedure

CREATE PROCEDURE DBO.UPDATE_REMARKS
-- Add the parameters for the stored procedure here
@TICK_ID VARCHAR(25),
@DATE VARCHAR(50),
@REMARK_TYPE VARCHAR(50),
@NOTES VARCHAR(1000)

AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

DECLARE @REMARK_ID VARCHAR(50)

SET @DATE = (SELECT CONVERT(VARCHAR, CONVERT(DATETIME, @DATE, 101), 101))

SET @REMARK_ID = (SELECT TICK_TYPE_ID FROM TICK_TYPE WHERE TICK_NAME = @REMARK_TYPE)

UPDATE TICKS SET TICK_DATE = @DATE, TICK_TYPE_ID = RTRIM(@REMARK_ID), NOTES = @NOTES WHERE TICK_ID = @TICK_ID

END

GO



Any help would be greatly appreciated.
Thanks in advance

 
That error is a .NET error. You need to find the line of code that it happens on. Also run through the debugger to find where it happens.
 
I have walked through on the debugger and it never errors out. It runs through smoothly except when the page reopens it has the error.
I have to admit I have not been using ASP.NET long so maybe I am missing something.
 
Have you tried using Try...Catch blocks around your data access portion of your code to catch errors?
 
Yes I have a try catch during the whole update part and it walks right threw.
 
What about when you select the data? You need try catches everywher you are accessing the DB. The error message you get should give you a line number and a code snippet where the error occurs.
 
Now thats a problem, I used the new wizards that tie the data to a control without having to type code. I was trying to get away from typing loads of code and I was told that the wizard is alot better than the older wizards
 
This is part of the reason why the wizards are bad. You will have to check the SP I guess. Usually this error means that you are trying to concatinate a string with a non-string type.
 
Ok
Thanks for your help and I suppose I will try to go the code way
Question
Do you know how I can call ddl that is in the GridView.
I don't see it in my list of controls.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top