Solved

Records not updating when using the commandfield update

Posted on 2006-12-01
7
284 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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,…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

930 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

10 Experts available now in Live!

Get 1:1 Help Now