I created an application in vb.net 2005. It works fine on my machine. I tested several different test machines and all were working fine. As for the client, it's generating an error. My application reads from an excel sheet and imports the values to an oracle database. the error being generated is: "conversion from type string to type double is not valid". Why is it generating only on the client's computer and not mine?
string to double
Collapse
X
-
-
Could it have something to do with the regional settings on the machines? This often creates a difference between e.g. 0,13 and 0.13.
StevenComment
-
Are you testing with the same test materials?
Spreadsheet Alpha works just fine on your machine and your other test machines but spreadsheet Bravo fails at the client. Could indicate that spreadsheet Bravo is not set up the same as the test subject they gave you and that you are not checking for the possibility that a value might not be right.
This can only work if the cell actually has a number. What if it doesn't? When coding you have to account for the possibility that the world is not perfect. Wrap it in a try/catch for starters and work your way out from there. MessageBox with error statement in the catch construct might help.deci = CDec(dt.Rows(i) .Item(13))Comment
-
When this type of error pops up, its almost always a regional thing. Differences between , and . and whatnot. Need to specify the correct region/culture for the data being parsed, and not just the default region/culture
I also recomend using the .NET conversions instead of the old VB conversions:
Double.Parse() or Double.TryParse ()Comment
-
Did you also check for non-numerical values? When there is a letter or a special character in the cell it also cannot be converted to double.
StevenComment
-
Perhaps you should be checking the object type first:
dt.Rows(i).Item (13).GetType(). ToString()
Make sure its what you think it should be (every time)
Then check that:
dt.Rows(i).Item (13).ToString()
is always something that can be parsed into a double?Comment
-
Or just check if it is numeric. If not, it can't be parsed into a double:
StevenCode:If IsNumeric(dt.Rows(i).Item(13).ToString())
Comment
-
But did you actually take anyone's advice? Put in some try/catch blocks in case something is not as it appears? Put in some 'if' conditionals to only do what you want 'if' the values were as expected? Put up some messageboxs or log files to report problems?Comment
-
I placed some Try/Catch blocks and managed to find out in which column in the excel sheet the error was being generated. I checked the whole column but i saw no letters or special characters there. But once again, if the column contained letters or empty value, shouldn't it generate an error on any computer??? This error is only being generated on one computer.Comment
-
Just because you don't see it, doesn't mean its not there. There are a lot of characters that are not displayable. Control codes for example.
So far.This error is only being generated on one computer.
There is a setting on that machine that is different than the other machines.But once again, if the column contained letters or empty value, shouldn't it generate an error on any computer???
Format of a date... country regionalization ... time format... thousands seperator character... Version of Excel on that one machine... somethingComment
-
Comment
Comment