Solved

ASP.Net Access Update not working

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

740 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