ive got a problems in updating the database in ms access, parameters wont work for me.
MS Access + vb.net 2010, can someone tell me the other ways of updating? im a biggener in vb.net
No one has an "Aladin's Light".
Post your code, how far you go and the exceptions you are facing.
Describe your problems, everyone hear to help you to solve your problems.
@Shark_1 , when i order i want the qty and price to update in database
tblsale : name[text] , qty [text], price[text]
heres my code:
sql = "UPDATE tblsale set qty = qty + '" & lvlist.FocusedItem.text & "price = price + qty + '" & lvlist.FocusedItem..SubItems(2).text & where name = '" & lvlist.FocusedItem.SubItems(1) Dim acscmd = New OleDb.OleDbCommand(sql, Con) acsdr = acscmd.ExecuteReader()
[its not working and i dont know where to put the calculation]
You want to update the database. But, ExecuteReader() uses to read data from a query .
To update data you will have to use ExecuteNonQuery() and by using ExecuteScalar() you can get the number of rows which are satiesfied your condition.
From my point of view, there is something wrong in your SQL statement. Use parameterised Sql query.
sql = "UPDATE tblsale set qty = qty + @qty, price = price + @price where name = @name" Dim acscmd As OleDb.OleDbCommand= New OleDb.OleDbCommand(sql, Con) acscmd.Parameters.AddWithValue("@qty", lvlist.FocusedItem.text) acscmd.Parameters.AddWithValue("@price", lvlist.FocusedItem..SubItems(2).text) acscmd.Parameters.AddWithValue("@name", lvlist.FocusedItem.SubItems(1).Text) acscmd.ExecuteNonQuery() acscmd.Dispose()