Solved

ASP.Net Access Update not working

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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…
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

910 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

24 Experts available now in Live!

Get 1:1 Help Now