?
Solved

ASP.Net Access Update not working

Posted on 2009-04-06
4
Medium Priority
?
212 Views
Last Modified: 2012-05-06
I have an access update query that was working last week and now when I try to run it nothing happens. I do not get an error message but the database is not getting updated. I run the same query in access and it works fine. Any Ideas why its not working now?
Dim con As New System.Data.OleDb.OleDbConnection
        Dim myPath As String
 
        myPath = Server.MapPath("App_Data/Visions_DB.mdb")
        con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data source=" & myPath & ";"
 
        Dim updCmd As New System.Data.OleDb.OleDbCommand
 
        updCmd.CommandText = "Update Data SET Present_Method=?,Proposed_Method=?,Status=?,Facilitator=?,Validator=?,Notes=?,Area=?,ValDate=? WHERE Vis_Num=?"
 
        '## Inserts values from form into Update command string ##
        updCmd.Parameters.AddWithValue("Present_Method", txtPresent.Text)
        updCmd.Parameters.AddWithValue("Proposed_Method", txtProposed.Text)
        updCmd.Parameters.AddWithValue("Status", ddstatus.SelectedValue)
        updCmd.Parameters.AddWithValue("Facilitator", ddFacilitator.SelectedValue)
        updCmd.Parameters.AddWithValue("Validator", txtImplement.Text)
        updCmd.Parameters.AddWithValue("Notes", txtNotes.Text)
        updCmd.Parameters.AddWithValue("ValDate", StartDatetxt.Text)
        updCmd.Parameters.AddWithValue("Vis_Num", txtVisNum.Text)
        updCmd.Parameters.AddWithValue("Area", ddArea.SelectedValue)
 
        updCmd.Connection = con
        con.Open()
        updCmd.ExecuteNonQuery()
        con.Close()

Open in new window

0
Comment
Question by:ITHelper80
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Author Comment

by:ITHelper80
ID: 24077661
I added some error checking....there are no exceptions and my return value from executenonquery is 0
0
 
LVL 2

Expert Comment

by:gandalf97
ID: 24077673
When I troubleshoot my own apps, the first question I always ask is "What Changed?"  Even if your first instinct is to say "Nothing changed.", something had to.  Figuring out what isn't always easy but it will help you figure things out.

Are you familiar with setting breakpoints and using the debugger?  Either your CommandText string does not contain what you think it does or one/more of your parameters are messed up.  Also check to make sure you aren't trying to insert a record where the primary key is duplicated.

Does this help?

Regards,
Gandalf
0
 
LVL 15

Accepted Solution

by:
oobayly earned 2000 total points
ID: 24077698
It looks like the ordering of your parameters has changed. As the parameters aren't named order is important:
http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbcommand.parameters.aspx
        updCmd.Parameters.AddWithValue("Present_Method", txtPresent.Text)
        updCmd.Parameters.AddWithValue("Proposed_Method", txtProposed.Text)
        updCmd.Parameters.AddWithValue("Status", ddstatus.SelectedValue)
        updCmd.Parameters.AddWithValue("Facilitator", ddFacilitator.SelectedValue)
        updCmd.Parameters.AddWithValue("Validator", txtImplement.Text)
        updCmd.Parameters.AddWithValue("Notes", txtNotes.Text)
        updCmd.Parameters.AddWithValue("Area", ddArea.SelectedValue)
        updCmd.Parameters.AddWithValue("ValDate", StartDatetxt.Text)
        updCmd.Parameters.AddWithValue("Vis_Num", txtVisNum.Text)

Open in new window

0
 
LVL 6

Author Comment

by:ITHelper80
ID: 24077725
Thaks oobayly

That was the problem....
0

Featured Post

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question