Converting text to double

Discussion in 'ASP .Net' started by Frederik Vanderhaeghe, Apr 18, 2006.

  1. 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
    Frederik Vanderhaeghe, Apr 18, 2006
    #1
    1. Advertising

  2. Frederik Vanderhaeghe

    pvdg42 Guest

    "Frederik Vanderhaeghe" <> wrote in message
    news:%...
    > 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.
    pvdg42, Apr 18, 2006
    #2
    1. Advertising

  3. Frederik Vanderhaeghe

    Pipo Guest

    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" <> wrote in message
    news:%...
    > 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
    >
    >
    Pipo, Apr 18, 2006
    #3
  4. but the problem is the "cast(bedrag as numeric(10,2)"
    bedrag=databasefield
    "Pipo" <> wrote in message
    news:...
    >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" <> wrote in message
    > news:%...
    >> 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
    >>
    >>

    >
    >
    Frederik Vanderhaeghe, Apr 18, 2006
    #4
  5. Frederik Vanderhaeghe

    Jeff Dillon Guest

    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" <> wrote in message
    news:...
    > but the problem is the "cast(bedrag as numeric(10,2)"
    > bedrag=databasefield
    > "Pipo" <> wrote in message
    > news:...
    >>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" <> wrote in message
    >> news:%...
    >>> 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
    >>>
    >>>

    >>
    >>

    >
    >
    Jeff Dillon, Apr 18, 2006
    #5
  6. 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" <> wrote in message
    news:%...
    > 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" <> wrote in message
    > news:...
    >> but the problem is the "cast(bedrag as numeric(10,2)"
    >> bedrag=databasefield
    >> "Pipo" <> wrote in message
    >> news:...
    >>>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" <> wrote in
    >>> message news:%...
    >>>> 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
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
    Frederik Vanderhaeghe, Apr 19, 2006
    #6
  7. Frederik Vanderhaeghe

    Pipo Guest

    What is the value of bedrag then?
    Are you trying to convert text to a double?
    Double.Parse("SomeText") wont work ofcourse.

    "Frederik Vanderhaeghe" <> wrote in message
    news:%...
    > 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" <> wrote in message
    > news:%...
    >> 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" <> wrote in message
    >> news:...
    >>> but the problem is the "cast(bedrag as numeric(10,2)"
    >>> bedrag=databasefield
    >>> "Pipo" <> wrote in message
    >>> news:...
    >>>>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" <> wrote in
    >>>> message news:%...
    >>>>> 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
    >>>>>
    >>>>>
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
    Pipo, Apr 19, 2006
    #7
  8. 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" <> wrote in message
    news:...
    > What is the value of bedrag then?
    > Are you trying to convert text to a double?
    > Double.Parse("SomeText") wont work ofcourse.
    >
    > "Frederik Vanderhaeghe" <> wrote in message
    > news:%...
    >> 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" <> wrote in message
    >> news:%...
    >>> 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" <> wrote in
    >>> message news:...
    >>>> but the problem is the "cast(bedrag as numeric(10,2)"
    >>>> bedrag=databasefield
    >>>> "Pipo" <> wrote in message
    >>>> news:...
    >>>>>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" <> wrote in
    >>>>> message news:%...
    >>>>>> 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
    >>>>>>
    >>>>>>
    >>>>>
    >>>>>
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
    Frederik Vanderhaeghe, Apr 19, 2006
    #8
  9. Frederik Vanderhaeghe

    Jeff Dillon Guest

    Post the exact line, and the value of all variables, that is generating the
    error. You can use CDbl too

    Jeff
    "Frederik Vanderhaeghe" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:...
    >> What is the value of bedrag then?
    >> Are you trying to convert text to a double?
    >> Double.Parse("SomeText") wont work ofcourse.
    >>
    >> "Frederik Vanderhaeghe" <> wrote in message
    >> news:%...
    >>> 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" <> wrote in message
    >>> news:%...
    >>>> 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" <> wrote in
    >>>> message news:...
    >>>>> but the problem is the "cast(bedrag as numeric(10,2)"
    >>>>> bedrag=databasefield
    >>>>> "Pipo" <> wrote in message
    >>>>> news:...
    >>>>>>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" <> wrote in
    >>>>>> message news:%...
    >>>>>>> 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
    >>>>>>>
    >>>>>>>
    >>>>>>
    >>>>>>
    >>>>>
    >>>>>
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
    Jeff Dillon, Apr 19, 2006
    #9
  10. whereSQL += "cast(bedrag as numeric(10,2)) > '" &
    > Double.Parse(txtdocbedrag.Text) & "' and "


    Bedrag = varchar with a

    "Jeff Dillon" <> wrote in message
    news:...
    > Post the exact line, and the value of all variables, that is generating
    > the error. You can use CDbl too
    >
    > Jeff
    > "Frederik Vanderhaeghe" <> wrote in message
    > news:...
    >> 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" <> wrote in message
    >> news:...
    >>> What is the value of bedrag then?
    >>> Are you trying to convert text to a double?
    >>> Double.Parse("SomeText") wont work ofcourse.
    >>>
    >>> "Frederik Vanderhaeghe" <> wrote in
    >>> message news:%...
    >>>> 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" <> wrote in message
    >>>> news:%...
    >>>>> 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" <> wrote in
    >>>>> message news:...
    >>>>>> but the problem is the "cast(bedrag as numeric(10,2)"
    >>>>>> bedrag=databasefield
    >>>>>> "Pipo" <> wrote in message
    >>>>>> news:...
    >>>>>>>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" <> wrote in
    >>>>>>> message news:%...
    >>>>>>>> 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
    >>>>>>>>
    >>>>>>>>
    >>>>>>>
    >>>>>>>
    >>>>>>
    >>>>>>
    >>>>>
    >>>>>
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
    Frederik Vanderhaeghe, Apr 20, 2006
    #10
  11. Frederik Vanderhaeghe

    Jeff Dillon Guest

    then don't do that (?)

    Obviously double.parse is failing. Catch the exception, and debug the
    results.

    Response.write, instead of issuing the sql (duh)

    txtdocbedrag.text contains text you don't expect. Find out why

    I find it amazing, and almost sad, the programmers these days can't figure
    out reproducible problems.

    I'm 50. I had issues like this 25 years ago, but before newgroups, granted.

    Just my opinion



    "Frederik Vanderhaeghe" <> wrote in message
    news:%...
    > whereSQL += "cast(bedrag as numeric(10,2)) > '" &
    >> Double.Parse(txtdocbedrag.Text) & "' and "

    >
    > Bedrag = varchar with a
    >
    > "Jeff Dillon" <> wrote in message
    > news:...
    >> Post the exact line, and the value of all variables, that is generating
    >> the error. You can use CDbl too
    >>
    Jeff Dillon, Apr 21, 2006
    #11
  12. It's not the double.parse that is failing, its the convert in sql!

    "Jeff Dillon" <> wrote in message
    news:uq$...
    > then don't do that (?)
    >
    > Obviously double.parse is failing. Catch the exception, and debug the
    > results.
    >
    > Response.write, instead of issuing the sql (duh)
    >
    > txtdocbedrag.text contains text you don't expect. Find out why
    >
    > I find it amazing, and almost sad, the programmers these days can't figure
    > out reproducible problems.
    >
    > I'm 50. I had issues like this 25 years ago, but before newgroups,
    > granted.
    >
    > Just my opinion
    >
    >
    >
    > "Frederik Vanderhaeghe" <> wrote in message
    > news:%...
    >> whereSQL += "cast(bedrag as numeric(10,2)) > '" &
    >>> Double.Parse(txtdocbedrag.Text) & "' and "

    >>
    >> Bedrag = varchar with a
    >>
    >> "Jeff Dillon" <> wrote in message
    >> news:...
    >>> Post the exact line, and the value of all variables, that is generating
    >>> the error. You can use CDbl too
    >>>

    >
    >
    Frederik Vanderhaeghe, Apr 21, 2006
    #12
  13. Frederik Vanderhaeghe

    Jeff Dillon Guest

    Please show the resultant SQL

    response.write strSQL

    but don't actually execute it.

    Jeff

    "Frederik Vanderhaeghe" <> wrote in message
    news:...
    > It's not the double.parse that is failing, its the convert in sql!
    >
    > "Jeff Dillon" <> wrote in message
    > news:uq$...
    >> then don't do that (?)
    >>
    >> Obviously double.parse is failing. Catch the exception, and debug the
    >> results.
    >>
    >> Response.write, instead of issuing the sql (duh)
    >>
    >> txtdocbedrag.text contains text you don't expect. Find out why
    >>
    >> I find it amazing, and almost sad, the programmers these days can't
    >> figure out reproducible problems.
    >>
    >> I'm 50. I had issues like this 25 years ago, but before newgroups,
    >> granted.
    >>
    >> Just my opinion
    >>
    >>
    >>
    >> "Frederik Vanderhaeghe" <> wrote in message
    >> news:%...
    >>> whereSQL += "cast(bedrag as numeric(10,2)) > '" &
    >>>> Double.Parse(txtdocbedrag.Text) & "' and "
    >>>
    >>> Bedrag = varchar with a
    >>>
    >>> "Jeff Dillon" <> wrote in message
    >>> news:...
    >>>> Post the exact line, and the value of all variables, that is generating
    >>>> the error. You can use CDbl too
    >>>>

    >>
    >>

    >
    >
    Jeff Dillon, Apr 21, 2006
    #13
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sydex
    Replies:
    12
    Views:
    6,454
    Victor Bazarov
    Feb 17, 2005
  2. Michael McGarry
    Replies:
    4
    Views:
    872
    Michael McGarry
    Nov 2, 2005
  3. Ole Nielsby

    double -> text -> double

    Ole Nielsby, Nov 29, 2006, in forum: C++
    Replies:
    11
    Views:
    551
    =?ISO-8859-1?Q?Tommi_H=F6yn=E4l=E4nmaa?=
    Nov 30, 2006
  4. Alfredo Agosti
    Replies:
    3
    Views:
    341
    Aaron Bertrand - MVP
    Sep 19, 2003
  5. Mike Green

    converting vertical text to horizontal text

    Mike Green, Feb 1, 2005, in forum: Perl Misc
    Replies:
    9
    Views:
    375
    Arndt Jonasson
    Feb 2, 2005
Loading...

Share This Page