Weird Bug On Client Machine

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BiffMaGriff
    New Member
    • Aug 2007
    • 39

    Weird Bug On Client Machine

    Hello,

    .Net 2.0
    I am creating a windows forms application for deployment on a client's machine.
    The program works fine on my local but the output on the client machine is wrong.
    Since the problem only occurs on the client's machine I cannot debug it.

    Essentially the program reads in data from an excell sheet, does some processing and then outputs to a text file the results.
    I convert the strings from the excel file to doubles and
    1.23 -> 0.23 10.23 -> 0.23 11.23 -> 1.23 12.23 -> 2.23 149.10 -> 49.10
    on the client's machine. Unfortunatly 0.24 stays as 0.24, same with 2.34 etc.
    So I can't fix the data after it has been read in.

    I am thinking that this problem has something to do with the client's excel settings on their machine.

    Using an OleDbConnection with connection string
    @"Provider=Micr osoft.Jet.OLEDB .4.0;Data Source={0};Exte nded Properties=Exce l 8.0;"
    I select * from my sheet and fill my dataset.

    I'm flabberghasted, I have no clue what is going on...

    Any ideas?

    Thanks,
    -Biff
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    I cannot figure out what you are doing to those numbers. At first I though you were just taking the portion after the decimal, then I thought you were subtracting 10..then I thought maybe you were removing the first digit.
    None of them seemed to fit.

    What you could try doing is, half the program read in the values from the excel sheet, and then write out what it thinks it got to a textfile (or whereever) and then write out a before and after value, see if you can see what is going on?

    Comment

    • BiffMaGriff
      New Member
      • Aug 2007
      • 39

      #3
      Originally posted by Plater
      I cannot figure out what you are doing to those numbers. At first I though you were just taking the portion after the decimal, then I thought you were subtracting 10..then I thought maybe you were removing the first digit.
      None of them seemed to fit.

      What you could try doing is, half the program read in the values from the excel sheet, and then write out what it thinks it got to a textfile (or whereever) and then write out a before and after value, see if you can see what is going on?
      Thanks for the reply!
      Yeah it is pretty bizzare alright. As far as I can tell if the number starts with a 1 it is clipped off.
      My program is trying to not do anything to the numbers hehe.

      In the meantime I've tried adding IMEX=1 to my connection string but the results were the same.

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        So if you tell your dataset to WriteXML() (or whatever it was called), it still is missing the first character?

        Comment

        • BiffMaGriff
          New Member
          • Aug 2007
          • 39

          #5
          Originally posted by Plater
          So if you tell your dataset to WriteXML() (or whatever it was called), it still is missing the first character?
          Hmm, writeXML gives correct values... I guess for some reason double.Parse on the client is not working the same as on my local...

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            you don't do anything wierd like assume the value starts with a " or anything like that do you?

            Comment

            • BiffMaGriff
              New Member
              • Aug 2007
              • 39

              #7
              Originally posted by Plater
              you don't do anything wierd like assume the value starts with a " or anything like that do you?
              This is essentially what I do.
              Code:
                          foreach (DataRow myRow in dataTable1.Rows)
              {
                  if (myRow["Column1"] != null && myRow["Column1"].ToString().Trim() != "")
                  {
                      myDoubleList.Add(double.Parse(myRow["Column1"].ToString()));
                  }
              }
              And then I spit that List of doubles to text file.

              Comment

              • BiffMaGriff
                New Member
                • Aug 2007
                • 39

                #8
                These results are off of my client's machine

                Text -> after double.Parse(). ToString()
                0.05 -> 0.05
                0.23 -> 0.23
                0.37 -> 0.37
                0.42 -> 0.42
                0.45 -> 0.45
                0.5 -> 0.5
                1.05 -> 0.05
                1.1 -> 0.1
                1.11 -> 0.11
                1.15 -> 0.15
                1.35 -> 0.35
                1.37 -> 0.37
                1.61 -> 0.61
                1.72 -> 0.72
                3.13 -> 3.13
                3.16 -> 3.16
                3.17 -> 3.17
                3.21 -> 3.21
                3.4 -> 3.4
                3.47 -> 3.47
                3.67 -> 3.67
                3.74 -> 3.74
                4.11 -> 4.11
                4.2 -> 4.2
                4.34 -> 4.34
                4.43 -> 4.43
                6.72 -> 6.72
                6.76 -> 6.76
                6.76 -> 6.76
                6.8 -> 6.8
                7.37 -> 7.37
                7.42 -> 7.42
                7.42 -> 7.42
                7.46 -> 7.46
                9.9 -> 9.9
                10.13 -> 0.13
                11.47 -> 1.47
                11.57 -> 1.57

                Comment

                • BiffMaGriff
                  New Member
                  • Aug 2007
                  • 39

                  #9
                  Maybe I'll add "1" to the begining of every string...

                  Comment

                  • Plater
                    Recognized Expert Expert
                    • Apr 2007
                    • 7872

                    #10
                    If all you are doing is writing them back to a text file, why do the double.parse() at all?
                    You could do a .TryParse() to make sure they are numerical data, then just write out the regular string.
                    does float.parse() work any better then double.prase()?

                    Comment

                    • BiffMaGriff
                      New Member
                      • Aug 2007
                      • 39

                      #11
                      Originally posted by Plater
                      If all you are doing is writing them back to a text file, why do the double.parse() at all?
                      You could do a .TryParse() to make sure they are numerical data, then just write out the regular string.
                      does float.parse() work any better then double.prase()?
                      I use the double to perform some calculations on other numbers. :)
                      Thanks for your input.

                      I finally solved the problem though.

                      I added

                      Code:
                      private static System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo("en-US");
                      myDoubleList.Add(double.Parse(myRow["Column1"].ToString(), cultureInfo));
                      I'm not sure what culture cuts off the leading 1s on all their numbers but I'm glad that this problem is solved. :D

                      Thanks again for your time Platter.
                      -Biff

                      Comment

                      • Plater
                        Recognized Expert Expert
                        • Apr 2007
                        • 7872

                        #12
                        Perhaps some culture specs mandate a leading sign character (+ / -) and it was just wipping it out?

                        Comment

                        Working...