Solved

Records not updating when using the commandfield update

Posted on 2006-12-01
7
288 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
Industry Leaders: 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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 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