Solved

ASP.Net Access Update not working

Posted on 2009-04-06
4
198 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now