Solved

ASP.Net Access Update not working

Posted on 2009-04-06
4
206 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
  • 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 500 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

770 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