Solved

Records not updating when using the commandfield update

Posted on 2006-12-01
7
281 Views
Last Modified: 2008-01-16
I am trying to use a Details view to display records from a datasource that I'd like to update.  When i click on the commandfield "update"  nothing is happening.  It looks like it does something but nothing is edite/updated in the  the Database.   Is there some poperties that must be set to ensure that the update works.  If not,  How do i get this to work.

My Updatecommand code is below


<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:cmConnectionString %>"
        SelectCommand="Select cm, FName, LName, Company, Address1, Address2, City, State, Zip, hphone, wphone, Fax, pname, SN, HomeEmail, eoptGeneral, eoptService, eoptMarketing, XL_Club, mk, pdate, sc From vcm  where cm= @ID union all Select  cm, FName, LName, Company, Address1, Address2, City, State, Zip, hphone, wphone, Fax, pname, SN, HomeEmail, eoptGeneral, eoptService, eoptMarketing, XL_Club, mk, pdate, sc  From vPSCust_Product where cm=@ID"
        UpdateCommand="UPDATE [tblcm] SET [Lname]=@lname, [Fname]=@fname, [hphone]=@phone, [wphone]=@wphone, [Homeemail]=@emailaddress, [address1]=@address,  [address2]=@address2, [city]=@city, [state]=@state, [zip]=@zip, [company]=@company, [Fax]=@fax, [pname]=@model, [SN]=@mod, [eoptGeneral]=@eoptgeneral, [eoptService]=@eoptservice, [eoptMarketing]=@eoptmarketing, [XL_Club] = @xlclub, [mk]= mk, [pdate]=@pdate, [sc]=@scustid  WHERE cm =@ID">
         <SelectParameters>
            <asp:QueryStringParameter Name="ID" QueryStringField="ID" />
        </SelectParameters>    
          <UpdateParameters>
            <asp:Parameter Name="lname" Type="String" />
            <asp:Parameter Name="fname" Type="String" />
            <asp:Parameter Name="phone" Type="String" />
            <asp:Parameter Name="wphone" Type="String" />
            <asp:Parameter Name="emailaddress"  Type="String"/>
            <asp:Parameter Name="address" Type="String" />
            <asp:Parameter Name="address2" Type="String" />
            <asp:Parameter Name="city" Type="String" />
            <asp:Parameter Name="state" Type="String" />
            <asp:Parameter Name="zip" Type="String" />
            <asp:Parameter Name="company" Type="String" />
            <asp:Parameter Name="fax" Type="String" />
            <asp:Parameter Name="model" Type="String" />
            <asp:Parameter Name="mod" Type="String" />
            <asp:Parameter Name="eoptgeneral" Type="String" />
            <asp:Parameter Name="eoptservice" Type="String" />
            <asp:Parameter Name="eoptmarketing" Type="String" />
            <asp:Parameter Name="xlclub" />
            <asp:Parameter Name="mk" Type="String" />
            <asp:Parameter Name="pdate"  />
            <asp:Parameter Name="scustid" />
            <asp:Parameter Name="ID" Type="Int32"  />
       
        </UpdateParameters>

    </asp:SqlDataSource></div>
0
Comment
Question by:krbnldy
  • 3
  • 2
7 Comments
 
LVL 10

Expert Comment

by:ibost
Comment Utility
If you're not getting any errors back, then the first thing I would check is that you are locating a record to update:

WHERE cm =@ID  <-- is @ID set to a valid record?
0
 

Author Comment

by:krbnldy
Comment Utility
I checked that and there is a valid record I am thinking that somehow in the .aspx page the ID is not passed correctly and I cannot see why. I am passing the ID from a differnet page.  See code below

  <asp:HyperLinkField  DataNavigateUrlFields="CM" DataNavigateUrlFormatString="updatecustomer.aspx?id={0}"
                    Text="EDIT"  NavigateUrl="updatecustomer.aspx?id={0}" DataTextFormatString="{0} ">
                <ControlStyle Font-Bold="True"  />
            </asp:HyperLinkField>
0
 

Author Comment

by:krbnldy
Comment Utility
I was able to get some fields to update but for some reason the majority of fields are not updating.  Is there a property I need to set?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:krbnldy
Comment Utility
I was able to answer my own question.  I am so new to this I did not realize that the parameter name being passed should be the same as the db field name in my instance.  When i changed the names it worked fine.

Please close this question.
0
 
LVL 10

Expert Comment

by:ibost
Comment Utility
Sounds good
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
Comment Utility
Closed, 60 points refunded.
DarthMod
Community Support Moderator
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

12 Experts available now in Live!

Get 1:1 Help Now