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
Solved

Records not updating when using the commandfield update

Posted on 2006-12-01
7
286 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASCX file or a newer alternative? 1 40
Delete HTML table rows 12 35
IEnumerable<T> to a List<T> 8 37
ASP.NET Content Page 3 27
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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 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