DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Access Database / Gridview Issues

  1. #1
    Join Date
    Jan 2008
    Posts
    1

    Access Database / Gridview Issues

    I am using Microsoft Expression to build my webpage in asp.net with VB backend. I have a gridview that displays my products (it successfully connects to the database and displays the correct info). Expression allows for me to have an "edit" column with it. When you click edit the labels of the gridview turn to textboxes and you can change their values. When I hit Update though I get "Object must implement IConvertible."

    I've done some reasearch on this and am coming away that it may be a bug? If this is correct can someone who uses VB explain why I'm getting this error and where to get the fix for it. Or more likley, it is a mistake on my end that I'm overlooking can anyone help me?

    Thanks in advance for the help!

    Sam

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Usually this error occurs either because a parameter value is invalid (such as passing TextBox1 instead of TextBox1.Text), or because you don't specify the command type (e.g. CommandType.StoredProcedure) in a command object.

    If that doesn't help you correct the error, please post your .aspx file.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Jan 2008
    Posts
    1
    I added a ".text" to the end of my "SelectedRow.cells(index)" and now the page passes successfully.

    Unfortunatley though, the values don't seem to be getting passed successfully as they are not updating and displaying the old values.

    I'll post my code below:
    Code:
    <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.SqlClient" %>	
    
        <script language="VB" runat="server">
        Sub Page_Load (sender As Object, e As System.EventArgs)
        	If Session("username") = String.empty Then
        	Response.Redirect("index.aspx")
        	End If
        End Sub
    
        </script>
        <form id="form1" runat="server">
    <asp:AccessDataSource runat="server" id="Data" DataFile="Database1.mdb" SelectCommand="SELECT [Thumbnail], [Product Name] AS Product_Name, [Quantity], [Product ID] AS Product_ID FROM [Inventory] WHERE ([Category] = ?)" DeleteCommand="DELETE FROM [Inventory] WHERE [Product ID] = ?" InsertCommand="INSERT INTO [Inventory] ([Thumbnail], [Product Name], [Quantity]) VALUES (?, ?, ?)" UpdateCommand="UPDATE [Inventory] SET [Thumbnail] = ?, [Product Name] = ?, [Quantity] = ? WHERE [Product ID] = ?">
    	<DeleteParameters>
    		<asp:parameter Type="Int32" Name="Product_ID" />
    	</DeleteParameters>
    	<UpdateParameters>
    		<asp:controlparameter Type="String" Name="Thumbnail" ControlID="gridview1" PropertyName="selectedrow.cells(0).text"/>
    		<asp:controlparameter Type="String" Name="Product_Name" ControlID="gridview1" PropertyName="selectedrow.cells(1).text"/>
    		<asp:controlparameter Type="Int32" Name="Quantity" ControlID="gridview1" PropertyName="selectedrow.cells(2).text"/>
    		<asp:parameter Type="Int32" Name="Product_ID" />
    	</UpdateParameters>
    	<SelectParameters>
    		<asp:controlparameter PropertyName="SelectedValue" Type="String" Name="Category" ControlID="DropDownList1" />
    	</SelectParameters>
    
    	<InsertParameters>
    		<asp:parameter Type="String" Name="Thumbnail" />
    		<asp:parameter Type="String" Name="Product_Name" />
    		<asp:parameter Type="Int32" Name="Quantity" />
    	</InsertParameters>
    
    </asp:AccessDataSource>
    
    <head>
    <title>Colornet Printing & Graphics Fufillment</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
    @import url('main.css');
    </style>
    </head>
    
    <body>
    
    <div id="masthead">
    	<div id="top_left">
    	<!--#include file="header.inc"-->
    	</div>
    	<div id="header">
    	Fulfillment Central
    	</div>
    </div>
    <div id="container">
    	<div id="left_col">
    	<asp:DropDownList runat="server" id="DropDownList1" DataTextField="Category" DataSourceID="AccessDataSource1" DataValueField="Category" AutoPostBack="True"></asp:DropDownList>
    	<asp:AccessDataSource runat="server" ID="AccessDataSource1" DataFile="Database1.mdb" SelectCommand="SELECT DISTINCT [Category], [Company] FROM [Inventory]">
    	</asp:AccessDataSource>
    	<br>
    	<!--#include file="menu.inc"-->
    	</div>
    	<div id="page_content"><br><br>
    		<asp:GridView runat="server" id="GridView1" AutoGenerateColumns="False" DataSourceID="Data" AllowSorting="True" 
    		AllowPaging="True" PageSize="5">
    		<Columns>
    			<asp:commandfield ShowSelectButton="True" ShowEditButton="True">
    			</asp:commandfield>
    			<asp:imagefield DataImageUrlField="Thumbnail" NullImageUrl="Images/np.jpg" SortExpression="Thumbnail">
    			</asp:imagefield>
    			<asp:boundfield DataField="Product_Name" SortExpression="Product_Name" HeaderText="Product_Name">
    			</asp:boundfield>
    			<asp:boundfield DataField="Quantity" SortExpression="Quantity" HeaderText="Quantity on Hand">
    			</asp:boundfield>
    		</Columns>
    	</asp:GridView>
    <asp:AccessDataSource runat="server" id="AccessDataSource2" DeleteCommand="DELETE FROM [Inventory Adjustment History] WHERE [ID] = ? AND [Item Description] = ? AND [Quantity Change] = ? AND [New Quanitity] = ? AND [User] = ? AND [Explanation] = ? AND [Date/Time] = ?" DataFile="Database1.mdb" InsertCommand="INSERT INTO [Inventory Adjustment History] ([Item Description], [Quantity Change], [New Quanitity], [User], [Explanation], [Date/Time]) VALUES (?, ?, ?, ?, ?, ?)" UpdateCommand="UPDATE [Inventory Adjustment History] SET [Item Description] = ?, [Quantity Change] = ?, [New Quanitity] = ?, [User] = ?, [Explanation] = ?, [Date/Time] = ? WHERE [ID] = ? AND [Item Description] = ? AND [Quantity Change] = ? AND [New Quanitity] = ? AND [User] = ? AND [Explanation] = ? AND [Date/Time] = ?" OldValuesParameterFormatString="original_{0}" ConflictDetection="CompareAllValues" SelectCommand="SELECT [ID], [Item Description] AS Item_Description, [Quantity Change] AS Quantity_Change, [New Quanitity] AS New_Quanitity, [User], [Explanation], [Date/Time] AS column1 FROM [Inventory Adjustment History]">
    	<DeleteParameters>
    		<asp:parameter Type="Int32" Name="original_ID" />
    		<asp:parameter Type="String" Name="original_Item_Description" />
    		<asp:parameter Type="String" Name="original_Quantity_Change" />
    		<asp:parameter Type="String" Name="original_New_Quanitity" />
    		<asp:parameter Type="String" Name="original_User" />
    		<asp:parameter Type="String" Name="original_Explanation" />
    		<asp:parameter Type="String" Name="original_column1" />
    	</DeleteParameters>
    	<UpdateParameters>
    		<asp:parameter Type="String" Name="Item_Description" />
    		<asp:parameter Type="String" Name="Quantity_Change" />
    		<asp:parameter Type="String" Name="New_Quanitity" />
    		<asp:parameter Type="String" Name="User" />
    		<asp:parameter Type="String" Name="Explanation" />
    		<asp:parameter Type="String" Name="column1" />
    		<asp:parameter Type="String" Name="original_ID" />
    		<asp:parameter Type="String" Name="original_Item_Description" />
    		<asp:parameter Type="String" Name="original_Quantity_Change" />
    		<asp:parameter Type="String" Name="original_New_Quanitity" />
    		<asp:parameter Type="String" Name="original_User" />
    		<asp:parameter Type="String" Name="original_Explanation" />
    		<asp:parameter Type="String" Name="original_column1" />
    	</UpdateParameters>
    	<InsertParameters>
    		<asp:Sessionparameter Type="String" Name="Item_Description" SessionField="PName"/>
    		<asp:Sessionparameter Type="String" Name="Quantity_Change" SessionField="Change"/>
    		<asp:Sessionparameter Type="String" Name="New_Quanitity" SessionField="Qty"/>
    		<asp:Sessionparameter Type="String" Name="User" SessionField="username"/>
    		<asp:Sessionparameter Type="String" Name="Explanation" />
    		<asp:SessionParameter Type="String" Name="column1" SessionField="Date_Time"/>
    	</InsertParameters>
    		</asp:AccessDataSource>
    	</div>
    </form>
    </body>
    
    </html>

Similar Threads

  1. asp, gridview, vb, MS access database
    By coolpgm in forum ASP.NET
    Replies: 1
    Last Post: 11-28-2006, 04:14 PM
  2. Replies: 2
    Last Post: 03-15-2002, 03:08 PM
  3. Replies: 0
    Last Post: 12-19-2000, 04:14 PM
  4. Replies: 0
    Last Post: 12-11-2000, 03:32 PM
  5. Save and Retrieve Picture In Access Database
    By Larry Rebich in forum VB Classic
    Replies: 3
    Last Post: 08-20-2000, 12:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center