Results 1 to 3 of 3

Thread: Updating decimals into Database

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2014
    Posts
    19

    Updating decimals into Database

    Hello there, been struggling with that, I cant work it out

    So I've got a database with a 'price' field, which is classified as a 'Currency' on MS Access.
    Then I've got a form wich I can either delete, add or edit the price of selected item.

    No problems with both adding items or deleting them. I can, for instance, insert 'cafe - 6,55' and it will work just fine.

    Now the problem is I want to be able to edit the price of that item, and to do so, I just make an update query to that field in the db, it should work fine and it does EXCEPT if the field in the edit textbox is not decimal, which means I can replace 6,50 for any integer, but it won't replace it for 7,40 for instance. It crashes and says that the Update sentence is not alright. I've tried to edit and transform it to string, to decimal, without success so far. Thats the sentence but I'm pretty sure the problem is on the type of the data, but I can't understand why Insert works, and Update doesnt, It's the same type of data.

    Code:
    cmd.CommandText = "UPDATE Items SET price =" & txtprice.Text & " WHERE id = " & id & ""
    cmd.ExecuteNonQuery()

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: Updating decimals into Database

    I can only guess that it is because you are using a comma as your decimal. Have you tried using 7.40 instead?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2014
    Posts
    19

    Re: Updating decimals into Database

    Quote Originally Posted by dee-u View Post
    I can only guess that it is because you are using a comma as your decimal. Have you tried using 7.40 instead?
    Oh my... It was as easy as that indeed!! Can't believe I didn't try it before, I was sure I did, thanks!

Posting Permissions

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



Click Here to Expand Forum to Full Width