Big Problem
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13

Thread: Big Problem

  1. #1
    Join Date
    Nov 2010
    Posts
    1

    Big Problem

    Plz i wont to know what is the wrong in this statement
    Dim SQL as string
    SQL = "update TBL_TEST_LIB set FEES='" & "' ,fees'" - AdjustAmount.Text & "'"

    CN.Execute SQL

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,845

    Re: Big Problem

    Assuming Fees is numeric in your DB then pretty much everything after the =
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,092

    Re: Big Problem

    Need way more info. What are you trying to do?

  4. #4
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,722

    Re: Big Problem

    The setting of quotes seems completely wrong to me.
    Assuming fees is numeric and you want to subtract the value in AdjyustAmount.Text then I'd say it should look like:
    Code:
    SQL = "update TBL_TEST_LIB set FEES= & (fees - Val(AdjustAmount.Text) & ";"

  5. #5
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    Talking Re: Big Problem

    Try the following way !

    Code:
    dim SQL$
    SQL = "update TBL_TEST_LIB set FEES=" & (fees - Val(AdjustAmount.Text) 
    CN.Execute SQL
    Last edited by firoz.raj; March 8th, 2012 at 12:36 PM.

  6. #6
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,845

    Re: Big Problem

    It is possible guys that Fees is not a variable within the program but rather the intent may be to reduce the current value of Fees in the database by the value of the text in the text box. In which case the select would need to be a bit different than any posted thus far.

    The op needs to provide info as to what he is actually trying to do.
    Always use [code][/code] tags when posting code.

  7. #7
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    Talking Re: Big Problem

    if fees is either integer or Long Variable then the following code will work fine .let me know .really what you want ? .
    Code:
    dim SQL$
    SQL = "update TBL_TEST_LIB set FEES=" & (fees - Val(AdjustAmount.Text) 
    CN.Execute SQL

  8. #8
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,722

    Re: Big Problem

    Oh. Seems I forgot a quote in my first answer.
    Ok, if DataMisers assumption is right and we want to reduce a field named FEES by a value then it must be:
    Code:
    SQL = "update TBL_TEST_LIB set FEES=FEES & " - " & AdjustAmount.Text
    where the text field must contain a valid numerical.

  9. #9
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    Talking Re: Big Problem

    HI Wof,
    it seems one more Inverted Comma is Needed .isn't it ?
    Code:
    SQL = "update TBL_TEST_LIB set FEES=" FEES & " - " & AdjustAmount.Text

  10. #10
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,722

    Re: Big Problem

    Oh... I forgot to delete the first & and following quote.
    Yes, firoz, it obviously is. But NOT in the place you are indicating.
    My final vote is
    Code:
    SQL = "update TBL_TEST_LIB set FEES=FEES - " & AdjustAmount.Text
    FEES is a field name of the table. It is not known stand-alone outside the SQL string.
    The only thing outside the string which must be catenated with the & is the numeric value in the text field. Even the Minus sign must be within the string.

  11. #11
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    Smile Re: Big Problem

    The only thing outside the string which must be catenated with the & is the numeric value in the text field. Even the Minus sign must be within the string.
    oh yes, wof is really genious .i even did not notice . fees is a fieldName in a table TBL_TEST_LIB .

  12. #12
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,845

    Re: Big Problem

    Quote Originally Posted by firoz.raj View Post
    oh yes, wof is really genious .i even did not notice . fees is a fieldName in a table TBL_TEST_LIB .
    That is what I was talking about in Post #6

    The code posted by WOF is probably what he needs but since the OP did not explain what he was trying to do it is not possible to be sure.
    Always use [code][/code] tags when posting code.

  13. #13
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,722

    Re: Big Problem

    We could produce some more proposals while waiting for a reply of the OP.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center