Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Professionals
|
ASP.NET 3.5 Professionals If you are an experienced ASP.NET programmer, this is the forum for your 3.5 questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Professionals section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 28th, 2010, 03:11 PM
Registered User
 
Join Date: May 2010
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
Default Problem with updating database based on user input

Let me explain what i am trying to do.

I am creating a number of webforms that allow a building manager to receive forms from managers requesting for equipment, offices, etc for new employees or existing employees. In one webform the building manager can click a GetForm button that will get the information from a MS Access Database and show the form with all the data filled out based on what was saved by a manager. If the building manager wants to change something he clicks a button to enable all the controls and can change any textbox or checkbox on the page. After that he/she clicks an Update button that calls a function that grabs the params and updates the database. However when update is clicked nothing is updated but no errors are thrown. In MS Access I tested the query and it works. What could i be missing?

Source Page(edited out some params to make more readable):
Code:
                <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/aDatabase.mdb" 
        SelectCommand="SELECT * FROM [Requests]"
        UpdateCommand="UPDATE [Requests] SET [Requester Name] = ?, //...some 60 params later [Special Instructions] = ? WHERE [ID] = ?">
        <UpdateParameters>
            <asp:FormParameter Name="Requester Name"  />
              //...some 60 params later
            <asp:FormParameter Name="Special Instructions"  />
            <asp:Parameter Name="ID"  />
        </UpdateParameters>
    </asp:AccessDataSource>
Code Behind Update Button Click:
Code:
    protected void btn_update_Click(object sender, EventArgs e)
    {
        GridView1.Enabled = false;
       

        string eN = Request.QueryString["form"];
        string dE = decryptQueryString(eN);


        AccessDataSource1.UpdateParameters["Requester Name"].DefaultValue = txb_rqstname.Text;
        AccessDataSource1.UpdateParameters["Special Instructions"].DefaultValue = txbx_SpecialInstructions.Text;
        AccessDataSource1.UpdateParameters["ID"].DefaultValue = dE;

        for (int x = 0; x < 60; x++)
        {
            //debug       Response.Write(AccessDataSource1.UpdateParameters[x].DefaultValue + " ");
        }

        AccessDataSource1.Update();
        //Response.Redirect("UpdateSuccessful.aspx");
    }
 
Old May 28th, 2010, 06:26 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Two things you could look into:

1. Do very simply updates work? That is, are you sure you can write to the database?

2. Is the WHERE clause OK? Do you assign it a valid ID?

3. Do all your parameters match? Because of the index based nature of Access queries you may have missed one and never assign the ID.....

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
b_clodius (June 1st, 2010)
 
Old June 1st, 2010, 12:10 PM
Registered User
 
Join Date: May 2010
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Woohoo I got it!

Thanks for the suggestions Imar, i had already done them but did them again, after further investigation and realization that nothing was changing i fixed the PageLoad event by wrapping all the code in a !PostBack and that did the trick.

Thanks again





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Updating MS Access database javlet Java Databases 1 April 24th, 2007 07:16 AM
Problem getting updating Database from Datagrid RichardP ASP.NET 1.0 and 1.1 Basics 0 February 17th, 2006 07:55 AM
updating the user database ali786 Classic ASP Databases 1 March 11th, 2005 05:04 AM
Updating Database Problem m4r7in PHP Databases 3 December 20th, 2004 12:01 PM
updating database problem nazra Classic ASP Databases 10 July 25th, 2003 08:27 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.