converting varchar to double

  • Thread starter Frederik Vanderhaeghe
  • Start date
F

Frederik Vanderhaeghe

Hi,

I try to cast/convert a varchar into a double but it doesn't work, i get an
error that it isn't possible to convert. What can I do?

The code is:
whereSQL += "cast(bedrag as numeric(10,2)) > '" &
Double.Parse(txtdocbedrag.Text) & "' and "

Fré
 
Q

q

Double.Parse(txtdocbedrag.Text).ToString( )

(You are taking a string... making it a double... and then trying to
use it as a string. Why?)
 
R

Richard Troy-Rex

I don't have experiences on this.
But I have some confused issues.
I remembered it has type 'Double' in T-SQL
I think you should use instance of type 'Double' under .NET to store value
of type 'Double' under T-SQL but not type 'numeric'.
 
F

Frederik Vanderhaeghe

I'm not taking a string, making it double and then using it as a string
again.
In the database there is a field (bedrag) that is from the type varchar.
In my application I have a textbox in which the value is entered as text.
But I have to compare the database field with the textbox field if the value
is greater than, greater than or equal, ...
So I convert the database field to a double and I convert the textfield to a
double and then compare them, but the convert of the database field gives an
error:
Error converting data type varchar to numeric.
What do I have to do?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top