Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 156959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:25:06+00:00 2026-05-11T10:25:06+00:00

I have a new laptop at work and code that worked earlier in the

  • 0

I have a new laptop at work and code that worked earlier in the week does not work today.

The code that worked before is, simplified:

while (dr.Read()) {     int i = int.Parse(dr.GetString(1)) } 

Now it fails when the database value is 0. Sometimes, but not reliably, this will work instead:

while (dr.Read()) {     int i = Convert.ToInt32(dr['FieldName'])) } 

Am I missing something stupid?

Oddly enough, ReSharper is also having tons of weird errors with the same error message that I am getting with the above code: ‘input string was not in the correct format.’ (Starts before I even load a project.)

Any ideas? Anyone having any SP issues? I did try to make sure all my SPs were up-to-date when I got the machine.

EDIT: I understand how to use Try.Parse and error-handling. The code here is simplified. I am reading test cases from a database table. This column has only 0, 1, and 2 values. I have confirmed that. I broke this down putting the database field into a string variable s and then trying int.Parse(s). The code worked earlier this week and the database has not changed. The only thing that has changed is my environment.

To completely simplify the problem, this line of code throws an exception (‘input string was not in the correct format’):

 int.Parse('0'); 

EDIT: Thanks to everyone for helping me resolve this issue! The solution was forcing a reset of my language settings.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:25:07+00:00Added an answer on May 11, 2026 at 10:25 am

    A possible explanation:

    Basically, the problem was the sPositiveSign value under HKEY_CURRENT_USER\Control Panel\International being set to 0, which means the positive sign is ‘0’. Thus, while parsing the ‘positive sign 0′ is being cut off and then the rest of the string (”) is parsed as a number, which doesn’t work of course. This also explains why int.Parse(’00’) wasn’t a problem. Although you can’t set the positive sign to ‘0’ through the Control Panel, it’s still possible to do it through the registry, causing problems. No idea how the computer of the user in the post ended up with this wrong setting…

    Better yet, what is the output of this on your machine:

    Console.WriteLine(System.Globalization.NumberFormatInfo.GetInstance(null).PositiveSign); 

    I’m willing to bet yours prints out a 0… when mine prints out a + sign.

    I suggest checking your Control Panel > Regional and Language Options settings… if they appear normal, try changing them to something else than back to whatever language you’re using (I’m assuming English).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I work mainly on a desktop Mac but also have a laptop Mac that
I have new problem. My code: .method public static void Main() cil managed {
When we have new in C#, that personally I see only as a workaround
I have a new service that I have written and need to register it
I have a new ParameterPart entity that is related to a new InputOutputMap. The
I have a piece of code that looks like this: Algorithm a = null;
I currently have Office 2007 with BCM installed on my new laptop, and it's
I'm doing small GPS project. Before I work on 32-bit laptop and I had
I have a new laptop and attempted to install jdk-1_5_0_22-windows-amd64, jdk-1_5_0_22-windows-i586-p and jdk-6u22-windows-i586 without
i have new webcam. The software of the webcam can give out the webcam

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.