Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9
This is the forum to discuss the Wrox book Professional ASP.NET 2.0 Special Edition by Bill Evjen, Scott Hanselman, Devin Rader, Farhan Muhammad, Srinivasa Sivakumar; ISBN: 9780470041789
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 18th, 2006, 04:33 PM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default MySQL table not changing with Update in Gridview

I created a page to test the edit/update function of GridView with a MySQL database. The test page works correctly. When I attempt to apply the same code technique to the real page I need to use, the database does not change when I click Update in Edit mode. I've been over the code again and again and I can't figure out where I've gone wrong.

Below is my code for the page that doesn’t work. Please help!

<html>
<head>
</head>
<body bgcolor="#53868b">
<center>
<form runat="server">
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False" AutoGenerateEditButton="true" Width="2000px" DataSourceID="SqlDataSource1" PageSize="20"><
  FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White"/>
        <RowStyle BackColor="#E3EAEB" />
        <EditRowStyle BackColor="#FFCCCC" ForeColor="Black" Font-Bold="True" />
        <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
        <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="White" />
        <Columns>
        <asp:BoundField HeaderText="Botanical Name" DataField="Botanical_Name" SortExpression="Botanical_Name" ReadOnly="true" />
        <asp:BoundField HeaderText="Common Name" DataField="Common_Name" SortExpression="Common_Name" ReadOnly="True" />
        <asp:BoundField HeaderText="Order Date" DataField="Order_Date" SortExpression="Order_Date" HtmlEncode="False" DataFormatString="{0:d}" ReadOnly="True" />
        <asp:BoundField HeaderText="Ordered By" DataField="Ordered_By" SortExpression="Ordered_By" ReadOnly="True" />
        <asp:BoundField HeaderText="Size" DataField="Size" SortExpression="Size" />
        <asp:BoundField HeaderText="Price" DataField="Price" SortExpression="Price" HtmlEncode="False" DataFormatString="{0:n5}" />
        <asp:BoundField HeaderText="Quantity" DataField="Quantity" SortExpression="Quantity" HtmlEncode="False" DataFormatString="{0:n2}" />
        <asp:BoundField HeaderText="Vendor" DataField="Vendor" SortExpression="Vendor" ReadOnly="True" />
        <asp:BoundField HeaderText="PO" DataField="PO" SortExpression="PO" ReadOnly="true" />
        <asp:BoundField HeaderText="Delivery Date" DataField="Delivery_Date" SortExpression="Delivery_Date" HtmlEncode="False" DataFormatString="{0:d}" />
        <asp:BoundField HeaderText="Supplied By" DataField="Supplied_By" SortExpression="Supplied_By" />
        <asp:BoundField HeaderText="Delivered By" DataField="Delivered_By" SortExpression="Delivered_By" />
        <asp:BoundField HeaderText="Delivery Invoice" DataField="Delivery_Invoice" SortExpression="Delivery_Invoice" />
        <asp:BoundField HeaderText="Shipping Cost for Entire Shipment" DataField="Shipping_Cost" SortExpression="Shipping_Cost" HtmlEncode="False" DataFormatString="{0:c2}" />
        <asp:BoundField HeaderText="Total # of Plants in Shipment" DataField="NumberPlants" SortExpression="NumberPlants" HtmlEncode="False" DataFormatString="{0:n2}" />
        <asp:BoundField HeaderText="Tag Cost for This Plant" DataField="Tag_Cost" SortExpression="Tag_Cost" HtmlEncode="False" DataFormatString="{0:c2}" />
        <asp:BoundField HeaderText="Total Charge for This Plant" DataField="Total_Charge" SortExpression="Total_Charge" HtmlEncode="False" DataFormatString="{0:c2}" />
    SelectCommand="SELECT * FROM paid ORDER BY Vendor, PO, Invoice"
    UpdateCommand="UPDATE paid SET Size=?, Price=?, Quantity=?, Supplied_By=?, Delivered_By=?, Delivery_Invoice=?, Shipping_Cost=?, NumberPlants=?, Tag_Cost=?, Total_Charge=?, Vendor_Order=?, Invoice=?, Notes=? WHERE Botanical_Name=? AND PO=?">
    <UpdateParameters>
    <asp:Parameter Type="String" Name="Botanical_Name" />
    <asp:Parameter Type="String" Name="Common_Name" />
    <asp:Parameter Type="DateTime" Name="Order_Date" />
    <asp:Parameter Type="String" Name="Ordered_By" />
    <asp:Parameter Type="String" Name="Size" />
        <asp:BoundField HeaderText="Vendor Order #" DataField="Vendor_Order" SortExpression="Vendor_Order" />
        <asp:BoundField HeaderText="Invoice #" DataField="Invoice" SortExpression="Invoice" />
        <asp:BoundField HeaderText="Notes" DataField="Notes" SortExpression="Notes" />
        </Columns> </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:linersConnectionString %>" ProviderName="<%$ ConnectionStrings:linersConnectionString.ProviderN ame %>" <asp:Parameter Type="Double" Name="Price" Size="5" />
    <asp:Parameter Type="Double" Name="Quantity" Size="2" />
    <asp:Parameter Type="String" Name="Vendor" />
    <asp:Parameter Type="String" Name="PO" />
    <asp:Parameter Type="DateTime" Name="Delivery_Date" />
    <asp:Parameter Type="String" Name="Supplied_By" />
    <asp:Parameter Type="String" Name="Delivered_By" />
    <asp:Parameter Type="String" Name="Delivery_Invoice" />
    <asp:Parameter Type="Double" Name="Shipping_Cost" Size="2" />
    <asp:Parameter Type="Double" Name="NumberPlants" Size="2" />
    <asp:Parameter Type="Double" Name="Tag_Cost" Size="2" />
    <asp:Parameter Type="Double" Name="Total_Charge" Size="2" />
    <asp:Parameter Type="String" Name="Vendor_Order" />
    <asp:Parameter Type="String" Name="Invoice" />
    <asp:Parameter Type="String"[red] Name="Notes" />
    </UpdateParameters>
    </asp:SqlDataSource>
</form>
</center>
</body>
</html>
  #2 (permalink)  
Old May 19th, 2006, 08:31 AM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In my attempt to make this more readable with the colors, the order of the code got changed, so here it is after a simple cut/paste.

Any help on this would be greatly appreciated.

<html>
<head>
</head>
<body bgcolor="#53868b">
<center>
<form runat="server">
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False" AutoGenerateEditButton="true" Width="2000px" DataSourceID="SqlDataSource1" PageSize="20">
        <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
        <RowStyle BackColor="#E3EAEB" />
        <EditRowStyle BackColor="#FFCCCC" ForeColor="Black" Font-Bold="True" />
        <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
        <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="White" />
        <Columns>
        <asp:BoundField HeaderText="Botanical Name" DataField="Botanical_Name" SortExpression="Botanical_Name" ReadOnly="true"/>
        <asp:BoundField HeaderText="Common Name" DataField="Common_Name" SortExpression="Common_Name" ReadOnly="True"/>
        <asp:BoundField HeaderText="Order Date" DataField="Order_Date" SortExpression="Order_Date" HtmlEncode="False" DataFormatString="{0:d}" ReadOnly="True"/>
        <asp:BoundField HeaderText="Ordered By" DataField="Ordered_By" SortExpression="Ordered_By" ReadOnly="True"/>
        <asp:BoundField HeaderText="Size" DataField="Size" SortExpression="Size"/>
        <asp:BoundField HeaderText="Price" DataField="Price" SortExpression="Price" HtmlEncode="False" DataFormatString="{0:n5}"/>
        <asp:BoundField HeaderText="Quantity" DataField="Quantity" SortExpression="Quantity" HtmlEncode="False" DataFormatString="{0:n2}"/>
        <asp:BoundField HeaderText="Vendor" DataField="Vendor" SortExpression="Vendor" ReadOnly="True"/>
        <asp:BoundField HeaderText="PO" DataField="PO" SortExpression="PO" ReadOnly="true" />
        <asp:BoundField HeaderText="Delivery Date" DataField="Delivery_Date" SortExpression="Delivery_Date" HtmlEncode="False" DataFormatString="{0:d}" />
        <asp:BoundField HeaderText="Supplied By" DataField="Supplied_By" SortExpression="Supplied_By"/>
        <asp:BoundField HeaderText="Delivered By" DataField="Delivered_By" SortExpression="Delivered_By"/>
        <asp:BoundField HeaderText="Delivery Invoice" DataField="Delivery_Invoice" SortExpression="Delivery_Invoice"/>
        <asp:BoundField HeaderText="Shipping Cost for Entire Shipment" DataField="Shipping_Cost" SortExpression="Shipping_Cost" HtmlEncode="False" DataFormatString="{0:c2}"/>
        <asp:BoundField HeaderText="Total # of Plants in Shipment" DataField="NumberPlants" SortExpression="NumberPlants" HtmlEncode="False" DataFormatString="{0:n2}"/>
        <asp:BoundField HeaderText="Tag Cost for This Plant" DataField="Tag_Cost" SortExpression="Tag_Cost" HtmlEncode="False" DataFormatString="{0:c2}"/>
        <asp:BoundField HeaderText="Total Charge for This Plant" DataField="Total_Charge" SortExpression="Total_Charge" HtmlEncode="False" DataFormatString="{0:c2}"/>
        <asp:BoundField HeaderText="Vendor Order #" DataField="Vendor_Order" SortExpression="Vendor_Order"/>
        <asp:BoundField HeaderText="Invoice #" DataField="Invoice" SortExpression="Invoice"/>
        <asp:BoundField HeaderText="Notes" DataField="Notes" SortExpression="Notes"/>
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:linersConnectionString %>" ProviderName="<%$ ConnectionStrings:linersConnectionString.ProviderN ame %>"
    SelectCommand="SELECT * FROM paid ORDER BY Vendor, PO, Invoice"
    UpdateCommand="UPDATE paid SET Size=?, Price=?, Quantity=?, Supplied_By=?, Delivered_By=?, Delivery_Invoice=?, Shipping_Cost=?, NumberPlants=?, Tag_Cost=?, Total_Charge=?, Vendor_Order=?, Invoice=?, Notes=? WHERE Botanical_Name=? AND PO=?" CancelSelectOnNullParameter="false">
    <UpdateParameters>
    <asp:Parameter Type="String" Name="Botanical_Name" />
    <asp:Parameter Type="String" Name="Common_Name" />
    <asp:Parameter Type="DateTime" Name="Order_Date" />
    <asp:Parameter Type="String" Name="Ordered_By" />
    <asp:FormParameter Type="String" Name="Size"/>
    <asp:FormParameter Type="Double" Name="Price" Size="5"/>
    <asp:FormParameter Type="Double" Name="Quantity" Size="2"/>
    <asp:Parameter Type="String" Name="Vendor" />
    <asp:Parameter Type="String" Name="PO" />
    <asp:Parameter Type="DateTime" Name="Delivery_Date"/>
    <asp:FormParameter Type="String" Name="Supplied_By"/>
    <asp:FormParameter Type="String" Name="Delivered_By"/>
    <asp:FormParameter Type="String" Name="Delivery_Invoice"/>
    <asp:FormParameter Type="Double" Name="Shipping_Cost" Size="2" />
    <asp:FormParameter Type="Double" Name="NumberPlants" Size="2" />
    <asp:FormParameter Type="Double" Name="Tag_Cost" Size="2" />
    <asp:FormParameter Type="Double" Name="Total_Charge" Size="2" />
    <asp:FormParameter Type="String" Name="Vendor_Order" />
    <asp:FormParameter Type="String" Name="Invoice" />
    <asp:FormParameter Type="String" Name="Notes" />
    </UpdateParameters>
    </asp:SqlDataSource>
</form>
</center>
</body>
</html>
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't get GridView to update xr280xr ASP.NET 2.0 Professional 5 February 15th, 2008 12:45 PM
Dynamic changing value of a gridview button text elwappo ASP.NET 2.0 Professional 6 January 7th, 2008 07:39 AM
Changing row position of gridview at runtime rameshsamiappan ASP.NET 2.0 Basics 0 September 25th, 2006 10:02 AM
Changing password in MySql thegooner BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 May 24th, 2004 05:53 PM



All times are GMT -4. The time now is 04:31 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.