473,406 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

string to double

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?
Aug 13 '09 #1
13 3262
MrMancunian
569 Expert 512MB
@dandalero
Can you post the code that does this?

Steven
Aug 13 '09 #2
Dim deci As Decimal = 0
deci = CDec(dt.Rows(i).Item(13))

If Not IsDBNull(dt.Rows(i).Item(13)) AndAlso deci > 0 Then
.price = CDec(dt.Rows(i).Item(13))
End If

POITEM.price = .price
Aug 13 '09 #3
MrMancunian
569 Expert 512MB
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.

Steven
Aug 13 '09 #4
tlhintoq
3,525 Expert 2GB
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.
deci = CDec(dt.Rows(i).Item(13))
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.
Aug 13 '09 #5
Plater
7,872 Expert 4TB
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()
Aug 13 '09 #6
Regarding the regional settings, I checked both regional settings and they are exactly the same. As for the cell having a number, i checked the excel sheet and didn't find any null or empty values.
Aug 14 '09 #7
MrMancunian
569 Expert 512MB
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.

Steven
Aug 14 '09 #8
Plater
7,872 Expert 4TB
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?
Aug 14 '09 #9
MrMancunian
569 Expert 512MB
Or just check if it is numeric. If not, it can't be parsed into a double:

Expand|Select|Wrap|Line Numbers
  1. If IsNumeric(dt.Rows(i).Item(13).ToString())
Steven
Aug 14 '09 #10
tlhintoq
3,525 Expert 2GB
@dandalero
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?
Aug 14 '09 #11
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.
Aug 17 '09 #12
tlhintoq
3,525 Expert 2GB
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.

This error is only being generated on one computer.
So far.

But once again, if the column contained letters or empty value, shouldn't it generate an error on any computer???
There is a setting on that machine that is different than the other machines.
Format of a date... country regionalization... time format... thousands seperator character... Version of Excel on that one machine... something
Aug 17 '09 #13
Plater
7,872 Expert 4TB
@tlhintoq
Ooo that's a good one, a different version of office would also have different versions of Jet. I would go so far as to say a difference in office updates on one vs the other could cause troubles.
Aug 17 '09 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: cindy liu | last post by:
Hi, In .Net, how to convert a string to a double? Thanks in advance! Cindy
5
by: JustSomeGuy | last post by:
I have a string that looks like: "123.45:123.45" I am using sscanf "%f%*c%f" to extract the two floats and ignore the colon. However there may be more than two floats.... Is there perhaps a...
3
by: Boz | last post by:
Hi, I am trying to use string.Format() to output the value of a double. double da = 100000000000.99994; double db = 100000000000.9994; double dc = 100000000000.994; double dd =...
16
by: Charles Law | last post by:
I have a string similar to the following: " MyString 40 "Hello world" all " It contains white space that may be spaces or tabs, or a combination, and I want to produce an array...
6
by: karthi | last post by:
hi, I need user defined function that converts string to float in c. since the library function atof and strtod occupies large space in my processor memory I can't use it in my code. regards,...
3
by: sernamar | last post by:
Hi, I have the following base class class UnitOfMeasure { public: //... std::string& GetName() {return _uomName;}; //... protected:
84
by: Peter Olcott | last post by:
Is there anyway of doing this besides making my own string from scratch? union AnyType { std::string String; double Number; };
15
by: shiniskumar | last post by:
How to convert string to double? Ive got a double variable dTot; its value is 5.037717235E7 when i did FreemarkerTools.formatDecimal(dTot) i got it as string "50377172.35". now i want to...
1
by: ronaldgranados | last post by:
Hi, I developed an application that generates code to be dinamically execute with reflection. When I used reflection everything seems to work fine until I saw a handle and memory leak. ...
9
by: Bob M | last post by:
If I define an expression or equation, how can I retrieve that expression as string literal? I want to do this so that I could avoid repetitive typing (or copy/paste/change) the same thing at two...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.