Answered by:
Access Database not Updating

Question
-
User-565927763 posted
Hi, I am using MS Access Database and I have
Imports System.Data.OleDb
Protected Sub Button1_Click()
Dim con As New OleDbConnection con.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("ConStr")
con.Open()
Dim editrec As New OleDbCommand("Update Jobseeker SET Height = '" & TextBox6.Text & "', Weight = '" & TextBox7.Text & "' where IdNo = '" & Session("Id") & "' ", con)
editrec.ExecuteNonQuery()
End Sub
There is error in the code. But when I click update button, the request execute but my database doesn't get updated of the new values that I entered. Someone help me about this..
Monday, May 24, 2010 12:03 AM
Answers
-
User-821857111 posted
You need to check to see if Session("Id") contains a value, and there is a matching one in the database you are trying to update. You should also make sure you are not looking in one version of the database, but updating another somewhere, so if you have multiple copies of the database, check your connection string.
Also, you should use parameters: Parameter Queries in ASP.NET with MS Access
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, May 24, 2010 12:34 AM -
User-821857111 posted
If your values (Height, Id etc) are numeric values, the syntax you showed in your first post is wrong. You have incorrect delimiters. Try using parameters.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, May 24, 2010 12:55 AM
All replies
-
User-821857111 posted
You need to check to see if Session("Id") contains a value, and there is a matching one in the database you are trying to update. You should also make sure you are not looking in one version of the database, but updating another somewhere, so if you have multiple copies of the database, check your connection string.
Also, you should use parameters: Parameter Queries in ASP.NET with MS Access
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, May 24, 2010 12:34 AM -
User-565927763 posted
Yes . Session("Id") does have a value. I check it by using msgbox(Session("Id")) at form load. Also Im sure there is a match because In the form load, I populate all the textbox with the current value of from the database of that user.
I use OleDbDateReader to retrieve records and put into the textboxes. And Suddenly my update doesn't reflect the changes in my database when the request is sent.
Monday, May 24, 2010 12:42 AM -
User-821857111 posted
If your values (Height, Id etc) are numeric values, the syntax you showed in your first post is wrong. You have incorrect delimiters. Try using parameters.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, May 24, 2010 12:55 AM -
User-565927763 posted
Doesn't matter if they are numeric. They are all stored as text in the database. And also, Im testing values of by inputing letters or numbers both does not work. Still my database is not updated. I am using this syntax in VWD and also in VS. But now it seems it doesn't work for me
Monday, May 24, 2010 1:09 AM