Click here to Skip to main content
15,899,025 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My website just shut down suddenly. When trying to log on, I get the message below..

Server Error in '/' Application.

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 218: 'Add page link
Line 219: tmpStr = dr("page_path")
Line 220: If dr("page_external_link") IsNot DBNull.Value AndAlso dr("page_external_link") AndAlso dr("page_content") = 1 Then
Line 221: tmpStr &= """ onClick=""window.open(this.href); return false;"
Line 222: End If

Source File: G:\PleskVhosts\cerra.org\httpdocs\include\navigation.ascx Line: 220

Stack Trace:


[FormatException: Input string was not in a correct format.]
Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat) +181
Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat) +63

[InvalidCastException: Conversion from string "0</title><style>.ascx{display:bl" to type 'Double' is not valid.]
Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat) +207
Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value) +6
Microsoft.VisualBasic.CompilerServices.Operators.CompareObject2(Object Left, Object Right, Boolean TextCompare) +358
Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectEqual(Object Left, Object Right, Boolean TextCompare) +23
ASP.navigation.GenerateLeftNav(ArrayList& crumbArr, Int32 curDepth, Int32 startDepth, Int32 maxDepth) in G:\PleskVhosts\cerra.org\httpdocs\include\navigation.ascx:220
ASP.navigation.Initialize(String path) in G:\PleskVhosts\cerra.org\httpdocs\include\navigation.ascx:142
ASP.site_master.Page_Load() in G:\PleskVhosts\cerra.org\httpdocs\Site.master:31
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +9599177
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34274

What I have tried:

I really don't know what to try. I am able to access the code, but know nothing about coding and have nobody to turn to.
Posted
Updated 4-Mar-16 7:06am
Comments
RedDk 4-Mar-16 12:10pm    
Contact your website service provider. Stop paying the bill. Post more information; preferably something about the initial post that you understand. Something that gets you to thinking. Etc.
Patrice T 4-Mar-16 12:17pm    
contact the author of web site code.
Afzaal Ahmad Zeeshan 4-Mar-16 12:47pm    
The string was not in correct format; expected format.

The line of code would help you, us and answerer to help you. The same error is returned in case of parsing date objects, integer objects, floating-point objects and so on. But the line of code would make us more precise.
Richard Deeming 4-Mar-16 12:59pm    
The most likely explanation is that dr("page_content") is a string that doesn't contain a valid integer.

But as we can't see the query you're executing at that point, or the data it's returning, that's just a guess.
Scratch that - the data is in the error message, and it's clearly not a number.

This line has all kinds of problems:
If dr("page_external_link") IsNot DBNull.Value AndAlso dr("page_external_link") AndAlso dr("page_content") = 1 Then


First, the dr("page_external_link") IsNot DBNull.Value makes an assumption that "page_external_link" is going to return DBNull. If the item returned doesn't exist, it will be null, not DbNull.Value. The two are NOT the same and, when VB.NET goes to do an implicit conversion of DbNull to something else behind the scenes, it won't work.

The second one is where you've got the error coming from. The comparison of whatever comes back from dr("page_content") cannot be converted to an Integer. Chances are it's either Nothing or en empty string. Since you're comparing that to an integer, VB.NET is trying to do an implicit conversion for you and cannot convert that return value to an Integer. Quietly doing implicit conversion for you (without telling you!) is one of the things that VB is infamous for.

Pull those property calls to dr out into their own variables and this would have been much easier to diagnose.
 
Share this answer
 
Comments
Richard Deeming 4-Mar-16 13:07pm    
It's not an empty string - the inner exception shows the value from the database, which is clearly not a number.
Dave Kreskowiak 4-Mar-16 14:44pm    
I didn't read that far. I just looked at the code and went "Ewwww..."
You're trying to compare a string from the database (the page_content field) to the integer value 1. VB.NET is automatically trying to convert that string to a number for you.

But as you can see from the error, that column does not contain a number. It contains the string:
plain
0</title><style>.ascx{display:bl


The quick fix to get the site back up is to change your code so that it compares the string column to a string:
VB.NET
If dr("page_external_link") IsNot DBNull.Value AndAlso dr("page_external_link") AndAlso dr("page_content") = "1" Then


Then you'll need to fix your data, as it clearly has unexpected and invalid values in the page_content column. You'll also want to try to work out where that value came from, and add validation to prevent it from coming back.

If the column is only meant to contain integers, change the data type to int.
 
Share this answer
 
Comments
Member 12369991 4-Mar-16 13:35pm    
Thanks, Richard!!! This worked. I don't know how to fix my data. If you have any suggestions, that would be great.
Richard Deeming 4-Mar-16 13:44pm    
You'll need to connect to your database somehow, and examine and fix the data in whatever table is used in the query that loads your navigation control. How you do that will depend on your hosting company.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900