-
Jul 23rd, 2014, 02:16 AM
#1
Thread Starter
Junior Member
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()
-
Jul 23rd, 2014, 02:37 AM
#2
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?
-
Jul 23rd, 2014, 02:49 AM
#3
Thread Starter
Junior Member
Re: Updating decimals into Database
Originally Posted by dee-u
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|