Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Converting text to double

Reply
Thread Tools

Converting text to double

 
 
Frederik Vanderhaeghe
Guest
Posts: n/a
 
      04-18-2006
Hi,

I have a problem converting text to a double. Why doesn't the code work:
If Not (txtdocbedrag.Text = "") Then

Select Case ddlBedrag.SelectedIndex

Case 0

Case 1

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

Case 2

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

Case 3

whereSQL += "cast(bedrag as numeric(10,2)) < '" &
Double.Parse(txtdocbedrag.Text) & "' and "

Case 4

whereSQL += "cast(bedrag as numeric(10,2)) <= '" &
Double.Parse(txtdocbedrag.Text) & "' and "

Case 5

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

Case 6

whereSQL += "cast(bedrag as numeric(10,2)) >= '" &
Double.Parse(txtdocbedrag.Text) & "' cast(bedrag as numeric(10,2)) < '" &
Double.Parse(txtBedragTot.Text) & "' and "

End Select

End If


 
Reply With Quote
 
 
 
 
pvdg42
Guest
Posts: n/a
 
      04-18-2006

"Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi,
>
> I have a problem converting text to a double. Why doesn't the code work:
> If Not (txtdocbedrag.Text = "") Then
>
> Select Case ddlBedrag.SelectedIndex
>
> Case 0
>
> Case 1
>
> whereSQL += "cast(bedrag as numeric(10,2)) > '" &
> Double.Parse(txtdocbedrag.Text) & "' and "
>
> Case 2
>
> whereSQL += "cast(bedrag as numeric(10,2)) >= '" &
> Double.Parse(txtdocbedrag.Text) & "' and "
>
> Case 3
>
> whereSQL += "cast(bedrag as numeric(10,2)) < '" &
> Double.Parse(txtdocbedrag.Text) & "' and "
>
> Case 4
>
> whereSQL += "cast(bedrag as numeric(10,2)) <= '" &
> Double.Parse(txtdocbedrag.Text) & "' and "
>
> Case 5
>
> whereSQL += "cast(bedrag as numeric(10,2)) = '" &
> Double.Parse(txtdocbedrag.Text) & "' and "
>
> Case 6
>
> whereSQL += "cast(bedrag as numeric(10,2)) >= '" &
> Double.Parse(txtdocbedrag.Text) & "' cast(bedrag as numeric(10,2)) < '" &
> Double.Parse(txtBedragTot.Text) & "' and "
>
> End Select
>
> End If
>
>

One thing I spotted is the use of single quote punctuation around a numeric
value (the result of Double.Parse(...).
In your SQL query (that is what you're building, correct?), numeric values
should have no punctuation characters surrounding them. String values need
single quotes, as to dates (in SQL Server. Access date punctuation is the
#.).

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.


 
Reply With Quote
 
 
 
 
Pipo
Guest
Posts: n/a
 
      04-18-2006
I dont know but converting a string to a double does work:
Dim st As String = "2.0"
Dim d As Double
d = Double.Parse(st)


"Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi,
>
> I have a problem converting text to a double. Why doesn't the code work:
> If Not (txtdocbedrag.Text = "") Then
>
> Select Case ddlBedrag.SelectedIndex
>
> Case 0
>
> Case 1
>
> whereSQL += "cast(bedrag as numeric(10,2)) > '" &
> Double.Parse(txtdocbedrag.Text) & "' and "
>
> Case 2
>
> whereSQL += "cast(bedrag as numeric(10,2)) >= '" &
> Double.Parse(txtdocbedrag.Text) & "' and "
>
> Case 3
>
> whereSQL += "cast(bedrag as numeric(10,2)) < '" &
> Double.Parse(txtdocbedrag.Text) & "' and "
>
> Case 4
>
> whereSQL += "cast(bedrag as numeric(10,2)) <= '" &
> Double.Parse(txtdocbedrag.Text) & "' and "
>
> Case 5
>
> whereSQL += "cast(bedrag as numeric(10,2)) = '" &
> Double.Parse(txtdocbedrag.Text) & "' and "
>
> Case 6
>
> whereSQL += "cast(bedrag as numeric(10,2)) >= '" &
> Double.Parse(txtdocbedrag.Text) & "' cast(bedrag as numeric(10,2)) < '" &
> Double.Parse(txtBedragTot.Text) & "' and "
>
> End Select
>
> End If
>
>



 
Reply With Quote
 
Frederik Vanderhaeghe
Guest
Posts: n/a
 
      04-18-2006
but the problem is the "cast(bedrag as numeric(10,2)"
bedrag=databasefield
"Pipo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I dont know but converting a string to a double does work:
> Dim st As String = "2.0"
> Dim d As Double
> d = Double.Parse(st)
>
>
> "Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Hi,
>>
>> I have a problem converting text to a double. Why doesn't the code work:
>> If Not (txtdocbedrag.Text = "") Then
>>
>> Select Case ddlBedrag.SelectedIndex
>>
>> Case 0
>>
>> Case 1
>>
>> whereSQL += "cast(bedrag as numeric(10,2)) > '" &
>> Double.Parse(txtdocbedrag.Text) & "' and "
>>
>> Case 2
>>
>> whereSQL += "cast(bedrag as numeric(10,2)) >= '" &
>> Double.Parse(txtdocbedrag.Text) & "' and "
>>
>> Case 3
>>
>> whereSQL += "cast(bedrag as numeric(10,2)) < '" &
>> Double.Parse(txtdocbedrag.Text) & "' and "
>>
>> Case 4
>>
>> whereSQL += "cast(bedrag as numeric(10,2)) <= '" &
>> Double.Parse(txtdocbedrag.Text) & "' and "
>>
>> Case 5
>>
>> whereSQL += "cast(bedrag as numeric(10,2)) = '" &
>> Double.Parse(txtdocbedrag.Text) & "' and "
>>
>> Case 6
>>
>> whereSQL += "cast(bedrag as numeric(10,2)) >= '" &
>> Double.Parse(txtdocbedrag.Text) & "' cast(bedrag as numeric(10,2)) < '" &
>> Double.Parse(txtBedragTot.Text) & "' and "
>>
>> End Select
>>
>> End If
>>
>>

>
>



 
Reply With Quote
 
Jeff Dillon
Guest
Posts: n/a
 
      04-18-2006
Define "doesn't work". Are you getting an error?

And what kind of syntax is "bedrag=databasefield".

apples=oranges

May I suggest you use some sort of meaningful naming convention?

Jeff

"Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> but the problem is the "cast(bedrag as numeric(10,2)"
> bedrag=databasefield
> "Pipo" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I dont know but converting a string to a double does work:
>> Dim st As String = "2.0"
>> Dim d As Double
>> d = Double.Parse(st)
>>
>>
>> "Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>> Hi,
>>>
>>> I have a problem converting text to a double. Why doesn't the code work:
>>> If Not (txtdocbedrag.Text = "") Then
>>>
>>> Select Case ddlBedrag.SelectedIndex
>>>
>>> Case 0
>>>
>>> Case 1
>>>
>>> whereSQL += "cast(bedrag as numeric(10,2)) > '" &
>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>
>>> Case 2
>>>
>>> whereSQL += "cast(bedrag as numeric(10,2)) >= '" &
>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>
>>> Case 3
>>>
>>> whereSQL += "cast(bedrag as numeric(10,2)) < '" &
>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>
>>> Case 4
>>>
>>> whereSQL += "cast(bedrag as numeric(10,2)) <= '" &
>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>
>>> Case 5
>>>
>>> whereSQL += "cast(bedrag as numeric(10,2)) = '" &
>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>
>>> Case 6
>>>
>>> whereSQL += "cast(bedrag as numeric(10,2)) >= '" &
>>> Double.Parse(txtdocbedrag.Text) & "' cast(bedrag as numeric(10,2)) < '"
>>> & Double.Parse(txtBedragTot.Text) & "' and "
>>>
>>> End Select
>>>
>>> End If
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Frederik Vanderhaeghe
Guest
Posts: n/a
 
      04-19-2006
bedrag = databasefield is not a syntax it was just saying that it is a field
from the database, it's not in the code.
The eroor i get is: Error converting data type varchar to numeric

"Jeff Dillon" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Define "doesn't work". Are you getting an error?
>
> And what kind of syntax is "bedrag=databasefield".
>
> apples=oranges
>
> May I suggest you use some sort of meaningful naming convention?
>
> Jeff
>
> "Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> but the problem is the "cast(bedrag as numeric(10,2)"
>> bedrag=databasefield
>> "Pipo" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>>I dont know but converting a string to a double does work:
>>> Dim st As String = "2.0"
>>> Dim d As Double
>>> d = Double.Parse(st)
>>>
>>>
>>> "Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in
>>> message news:%(E-Mail Removed)...
>>>> Hi,
>>>>
>>>> I have a problem converting text to a double. Why doesn't the code
>>>> work:
>>>> If Not (txtdocbedrag.Text = "") Then
>>>>
>>>> Select Case ddlBedrag.SelectedIndex
>>>>
>>>> Case 0
>>>>
>>>> Case 1
>>>>
>>>> whereSQL += "cast(bedrag as numeric(10,2)) > '" &
>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>
>>>> Case 2
>>>>
>>>> whereSQL += "cast(bedrag as numeric(10,2)) >= '" &
>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>
>>>> Case 3
>>>>
>>>> whereSQL += "cast(bedrag as numeric(10,2)) < '" &
>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>
>>>> Case 4
>>>>
>>>> whereSQL += "cast(bedrag as numeric(10,2)) <= '" &
>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>
>>>> Case 5
>>>>
>>>> whereSQL += "cast(bedrag as numeric(10,2)) = '" &
>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>
>>>> Case 6
>>>>
>>>> whereSQL += "cast(bedrag as numeric(10,2)) >= '" &
>>>> Double.Parse(txtdocbedrag.Text) & "' cast(bedrag as numeric(10,2)) < '"
>>>> & Double.Parse(txtBedragTot.Text) & "' and "
>>>>
>>>> End Select
>>>>
>>>> End If
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Pipo
Guest
Posts: n/a
 
      04-19-2006
What is the value of bedrag then?
Are you trying to convert text to a double?
Double.Parse("SomeText") wont work ofcourse.

"Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> bedrag = databasefield is not a syntax it was just saying that it is a
> field from the database, it's not in the code.
> The eroor i get is: Error converting data type varchar to numeric
>
> "Jeff Dillon" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Define "doesn't work". Are you getting an error?
>>
>> And what kind of syntax is "bedrag=databasefield".
>>
>> apples=oranges
>>
>> May I suggest you use some sort of meaningful naming convention?
>>
>> Jeff
>>
>> "Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> but the problem is the "cast(bedrag as numeric(10,2)"
>>> bedrag=databasefield
>>> "Pipo" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>>I dont know but converting a string to a double does work:
>>>> Dim st As String = "2.0"
>>>> Dim d As Double
>>>> d = Double.Parse(st)
>>>>
>>>>
>>>> "Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in
>>>> message news:%(E-Mail Removed)...
>>>>> Hi,
>>>>>
>>>>> I have a problem converting text to a double. Why doesn't the code
>>>>> work:
>>>>> If Not (txtdocbedrag.Text = "") Then
>>>>>
>>>>> Select Case ddlBedrag.SelectedIndex
>>>>>
>>>>> Case 0
>>>>>
>>>>> Case 1
>>>>>
>>>>> whereSQL += "cast(bedrag as numeric(10,2)) > '" &
>>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>>
>>>>> Case 2
>>>>>
>>>>> whereSQL += "cast(bedrag as numeric(10,2)) >= '" &
>>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>>
>>>>> Case 3
>>>>>
>>>>> whereSQL += "cast(bedrag as numeric(10,2)) < '" &
>>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>>
>>>>> Case 4
>>>>>
>>>>> whereSQL += "cast(bedrag as numeric(10,2)) <= '" &
>>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>>
>>>>> Case 5
>>>>>
>>>>> whereSQL += "cast(bedrag as numeric(10,2)) = '" &
>>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>>
>>>>> Case 6
>>>>>
>>>>> whereSQL += "cast(bedrag as numeric(10,2)) >= '" &
>>>>> Double.Parse(txtdocbedrag.Text) & "' cast(bedrag as numeric(10,2)) <
>>>>> '" & Double.Parse(txtBedragTot.Text) & "' and "
>>>>>
>>>>> End Select
>>>>>
>>>>> End If
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Frederik Vanderhaeghe
Guest
Posts: n/a
 
      04-19-2006
bedrag is varchar in the database. I have to compare the varchar out of the
database with a value in a textbox, so i convert the varchar to double and i
parse the textbox value to double.
"Pipo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> What is the value of bedrag then?
> Are you trying to convert text to a double?
> Double.Parse("SomeText") wont work ofcourse.
>
> "Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> bedrag = databasefield is not a syntax it was just saying that it is a
>> field from the database, it's not in the code.
>> The eroor i get is: Error converting data type varchar to numeric
>>
>> "Jeff Dillon" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>> Define "doesn't work". Are you getting an error?
>>>
>>> And what kind of syntax is "bedrag=databasefield".
>>>
>>> apples=oranges
>>>
>>> May I suggest you use some sort of meaningful naming convention?
>>>
>>> Jeff
>>>
>>> "Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in
>>> message news:(E-Mail Removed)...
>>>> but the problem is the "cast(bedrag as numeric(10,2)"
>>>> bedrag=databasefield
>>>> "Pipo" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>>I dont know but converting a string to a double does work:
>>>>> Dim st As String = "2.0"
>>>>> Dim d As Double
>>>>> d = Double.Parse(st)
>>>>>
>>>>>
>>>>> "Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in
>>>>> message news:%(E-Mail Removed)...
>>>>>> Hi,
>>>>>>
>>>>>> I have a problem converting text to a double. Why doesn't the code
>>>>>> work:
>>>>>> If Not (txtdocbedrag.Text = "") Then
>>>>>>
>>>>>> Select Case ddlBedrag.SelectedIndex
>>>>>>
>>>>>> Case 0
>>>>>>
>>>>>> Case 1
>>>>>>
>>>>>> whereSQL += "cast(bedrag as numeric(10,2)) > '" &
>>>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>>>
>>>>>> Case 2
>>>>>>
>>>>>> whereSQL += "cast(bedrag as numeric(10,2)) >= '" &
>>>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>>>
>>>>>> Case 3
>>>>>>
>>>>>> whereSQL += "cast(bedrag as numeric(10,2)) < '" &
>>>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>>>
>>>>>> Case 4
>>>>>>
>>>>>> whereSQL += "cast(bedrag as numeric(10,2)) <= '" &
>>>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>>>
>>>>>> Case 5
>>>>>>
>>>>>> whereSQL += "cast(bedrag as numeric(10,2)) = '" &
>>>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>>>
>>>>>> Case 6
>>>>>>
>>>>>> whereSQL += "cast(bedrag as numeric(10,2)) >= '" &
>>>>>> Double.Parse(txtdocbedrag.Text) & "' cast(bedrag as numeric(10,2)) <
>>>>>> '" & Double.Parse(txtBedragTot.Text) & "' and "
>>>>>>
>>>>>> End Select
>>>>>>
>>>>>> End If
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Jeff Dillon
Guest
Posts: n/a
 
      04-19-2006
Post the exact line, and the value of all variables, that is generating the
error. You can use CDbl too

Jeff
"Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> bedrag is varchar in the database. I have to compare the varchar out of
> the database with a value in a textbox, so i convert the varchar to double
> and i parse the textbox value to double.
> "Pipo" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> What is the value of bedrag then?
>> Are you trying to convert text to a double?
>> Double.Parse("SomeText") wont work ofcourse.
>>
>> "Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>> bedrag = databasefield is not a syntax it was just saying that it is a
>>> field from the database, it's not in the code.
>>> The eroor i get is: Error converting data type varchar to numeric
>>>
>>> "Jeff Dillon" <(E-Mail Removed)> wrote in message
>>> news:%(E-Mail Removed)...
>>>> Define "doesn't work". Are you getting an error?
>>>>
>>>> And what kind of syntax is "bedrag=databasefield".
>>>>
>>>> apples=oranges
>>>>
>>>> May I suggest you use some sort of meaningful naming convention?
>>>>
>>>> Jeff
>>>>
>>>> "Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in
>>>> message news:(E-Mail Removed)...
>>>>> but the problem is the "cast(bedrag as numeric(10,2)"
>>>>> bedrag=databasefield
>>>>> "Pipo" <(E-Mail Removed)> wrote in message
>>>>> news:(E-Mail Removed)...
>>>>>>I dont know but converting a string to a double does work:
>>>>>> Dim st As String = "2.0"
>>>>>> Dim d As Double
>>>>>> d = Double.Parse(st)
>>>>>>
>>>>>>
>>>>>> "Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in
>>>>>> message news:%(E-Mail Removed)...
>>>>>>> Hi,
>>>>>>>
>>>>>>> I have a problem converting text to a double. Why doesn't the code
>>>>>>> work:
>>>>>>> If Not (txtdocbedrag.Text = "") Then
>>>>>>>
>>>>>>> Select Case ddlBedrag.SelectedIndex
>>>>>>>
>>>>>>> Case 0
>>>>>>>
>>>>>>> Case 1
>>>>>>>
>>>>>>> whereSQL += "cast(bedrag as numeric(10,2)) > '" &
>>>>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>>>>
>>>>>>> Case 2
>>>>>>>
>>>>>>> whereSQL += "cast(bedrag as numeric(10,2)) >= '" &
>>>>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>>>>
>>>>>>> Case 3
>>>>>>>
>>>>>>> whereSQL += "cast(bedrag as numeric(10,2)) < '" &
>>>>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>>>>
>>>>>>> Case 4
>>>>>>>
>>>>>>> whereSQL += "cast(bedrag as numeric(10,2)) <= '" &
>>>>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>>>>
>>>>>>> Case 5
>>>>>>>
>>>>>>> whereSQL += "cast(bedrag as numeric(10,2)) = '" &
>>>>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>>>>
>>>>>>> Case 6
>>>>>>>
>>>>>>> whereSQL += "cast(bedrag as numeric(10,2)) >= '" &
>>>>>>> Double.Parse(txtdocbedrag.Text) & "' cast(bedrag as numeric(10,2)) <
>>>>>>> '" & Double.Parse(txtBedragTot.Text) & "' and "
>>>>>>>
>>>>>>> End Select
>>>>>>>
>>>>>>> End If
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Frederik Vanderhaeghe
Guest
Posts: n/a
 
      04-20-2006
whereSQL += "cast(bedrag as numeric(10,2)) > '" &
> Double.Parse(txtdocbedrag.Text) & "' and "


Bedrag = varchar with a

"Jeff Dillon" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Post the exact line, and the value of all variables, that is generating
> the error. You can use CDbl too
>
> Jeff
> "Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> bedrag is varchar in the database. I have to compare the varchar out of
>> the database with a value in a textbox, so i convert the varchar to
>> double and i parse the textbox value to double.
>> "Pipo" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> What is the value of bedrag then?
>>> Are you trying to convert text to a double?
>>> Double.Parse("SomeText") wont work ofcourse.
>>>
>>> "Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in
>>> message news:%(E-Mail Removed)...
>>>> bedrag = databasefield is not a syntax it was just saying that it is a
>>>> field from the database, it's not in the code.
>>>> The eroor i get is: Error converting data type varchar to numeric
>>>>
>>>> "Jeff Dillon" <(E-Mail Removed)> wrote in message
>>>> news:%(E-Mail Removed)...
>>>>> Define "doesn't work". Are you getting an error?
>>>>>
>>>>> And what kind of syntax is "bedrag=databasefield".
>>>>>
>>>>> apples=oranges
>>>>>
>>>>> May I suggest you use some sort of meaningful naming convention?
>>>>>
>>>>> Jeff
>>>>>
>>>>> "Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in
>>>>> message news:(E-Mail Removed)...
>>>>>> but the problem is the "cast(bedrag as numeric(10,2)"
>>>>>> bedrag=databasefield
>>>>>> "Pipo" <(E-Mail Removed)> wrote in message
>>>>>> news:(E-Mail Removed)...
>>>>>>>I dont know but converting a string to a double does work:
>>>>>>> Dim st As String = "2.0"
>>>>>>> Dim d As Double
>>>>>>> d = Double.Parse(st)
>>>>>>>
>>>>>>>
>>>>>>> "Frederik Vanderhaeghe" <(E-Mail Removed)> wrote in
>>>>>>> message news:%(E-Mail Removed)...
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I have a problem converting text to a double. Why doesn't the code
>>>>>>>> work:
>>>>>>>> If Not (txtdocbedrag.Text = "") Then
>>>>>>>>
>>>>>>>> Select Case ddlBedrag.SelectedIndex
>>>>>>>>
>>>>>>>> Case 0
>>>>>>>>
>>>>>>>> Case 1
>>>>>>>>
>>>>>>>> whereSQL += "cast(bedrag as numeric(10,2)) > '" &
>>>>>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>>>>>
>>>>>>>> Case 2
>>>>>>>>
>>>>>>>> whereSQL += "cast(bedrag as numeric(10,2)) >= '" &
>>>>>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>>>>>
>>>>>>>> Case 3
>>>>>>>>
>>>>>>>> whereSQL += "cast(bedrag as numeric(10,2)) < '" &
>>>>>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>>>>>
>>>>>>>> Case 4
>>>>>>>>
>>>>>>>> whereSQL += "cast(bedrag as numeric(10,2)) <= '" &
>>>>>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>>>>>
>>>>>>>> Case 5
>>>>>>>>
>>>>>>>> whereSQL += "cast(bedrag as numeric(10,2)) = '" &
>>>>>>>> Double.Parse(txtdocbedrag.Text) & "' and "
>>>>>>>>
>>>>>>>> Case 6
>>>>>>>>
>>>>>>>> whereSQL += "cast(bedrag as numeric(10,2)) >= '" &
>>>>>>>> Double.Parse(txtdocbedrag.Text) & "' cast(bedrag as numeric(10,2))
>>>>>>>> < '" & Double.Parse(txtBedragTot.Text) & "' and "
>>>>>>>>
>>>>>>>> End Select
>>>>>>>>
>>>>>>>> End If
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
double -> text -> double Ole Nielsby C++ 11 11-30-2006 05:16 PM
Converting text in exponential form to double Michael McGarry C++ 4 11-02-2005 11:39 PM
cannot convert parameter from 'double (double)' to 'double (__cdecl *)(double)' error Sydex C++ 12 02-17-2005 06:30 PM
converting vertical text to horizontal text Mike Green Perl Misc 9 02-02-2005 08:56 AM
Content from a memo field: converting the rich text into plain text Alfredo Agosti ASP General 3 09-19-2003 05:01 PM



Advertisments