Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Records not updating when using the commandfield update

Posted on 2006-12-01
7
Medium Priority
?
291 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 10

Expert Comment

by:ibost
ID: 18056963
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
ID: 18068196
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
ID: 18069046
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:krbnldy
ID: 18069095
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
ID: 18077722
Sounds good
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 18106367
Closed, 60 points refunded.
DarthMod
Community Support Moderator
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

704 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