Submitting data to Access table using FormView control via aspx page
-
Thursday, November 15, 2012 3:48 AM
Greetings,
I am trying to use Expression Web to create aspx pages on a web site to CRUD with an existing table in an Access database. I found I can easily display that table data using a grid view layout and an accessdatasource controller. J
But for the CRUD part, I followed another online tutorial that half works. I used a FormView controller and linked it to the access table that resides in the web site folder. But when I run the page and try to insert data into the webform (running on a localhost server), only ONE field out of FOUR updates in the database. The field that shows is a memo datatype. So I changed the other fields to match but still only one field updated. I attach the code from the aspx file at then end of this message.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Page Language="C#" %>
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
</head>
<body>
<form id="form1" runat="server">
<asp:FormView id="Input_Form" runat="server" DataKeyNames="ID" DataSourceID="Game_Demo" DefaultMode="Insert">
<EditItemTemplate>
ID:
<asp:Label id="IDLabel1" runat="server" Text='<%# Eval("ID") %>' />
<br />
Game Name:
<asp:TextBox id="Game_NameTextBox" runat="server" Text='<%# Bind("[Game Name]") %>' />
<br />
Game Genre:
<asp:TextBox id="Game_GenreTextBox" runat="server" Text='<%# Bind("[Game Genre]") %>' />
<br />
Game Version:
<asp:TextBox id="Game_VersionTextBox" runat="server" Text='<%# Bind("[Game Version]") %>' />
<br />
Description:
<asp:TextBox id="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' />
<br />
<asp:LinkButton id="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" />
<asp:LinkButton id="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<InsertItemTemplate>
Game Name:
<asp:TextBox id="Game_NameTextBox" runat="server" Text='<%# Bind("[Game Name]") %>' />
<br />
Game Genre:
<asp:TextBox id="Game_GenreTextBox" runat="server" Text='<%# Bind("[Game Genre]") %>' />
<br />
Game Version:
<asp:TextBox id="Game_VersionTextBox" runat="server" Text='<%# Bind("[Game Version]") %>' />
<br />
Description:
<asp:TextBox id="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' />
<br />
<asp:LinkButton id="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" />
<asp:LinkButton id="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
<ItemTemplate>
ID:
<asp:Label id="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
<br />
Game Name:
<asp:Label id="Game_NameLabel" runat="server" Text='<%# Bind("[Game Name]") %>' />
<br />
Game Genre:
<asp:Label id="Game_GenreLabel" runat="server" Text='<%# Bind("[Game Genre]") %>' />
<br />
Game Version:
<asp:Label id="Game_VersionLabel" runat="server" Text='<%# Bind("[Game Version]") %>' />
<br />
Description:
<asp:Label id="DescriptionLabel" runat="server" Text='<%# Bind("Description") %>' />
<br />
<asp:LinkButton id="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" />
<asp:LinkButton id="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" />
<asp:LinkButton id="NewButton" runat="server" CausesValidation="False" CommandName="New" Text="New" />
</ItemTemplate>
</asp:FormView>
<asp:AccessDataSource ID="Game_Demo" runat="server" DataFile="Games Demo.accdb" DeleteCommand="DELETE FROM [Game Info] WHERE [ID] = ?" InsertCommand="INSERT INTO [Game Info] ([Game Name], [Game Genre], [Game Version], [Description]) VALUES (?, ?, ?, ?)" SelectCommand="SELECT * FROM [Game Info]" UpdateCommand="UPDATE [Game Info] SET [Game Name] = ?, [Game Genre] = ?, [Game Version] = ?, [Description] = ? WHERE [ID] = ?">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Game_Name" Type="String" />
<asp:Parameter Name="Game_Genre" Type="String" />
<asp:Parameter Name="Game_Version" Type="Double" />
<asp:Parameter Name="Description" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="Game_Name" Type="String" />
<asp:Parameter Name="Game_Genre" Type="String" />
<asp:Parameter Name="Game_Version" Type="Double" />
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
</asp:AccessDataSource>
</form>
</body>
</html>
All Replies
-
Thursday, November 15, 2012 1:37 PM
I don't know if this is causing your problem, but it is generally not a good idea to have spaces in your field names. Try fixing that and see if it helps.
ClarkNK, A.K.A. HomePage Doctor
HomePageDoctor.com -- Expression Web database tutorials
Ownertrades.com -- Created with Expression, VWDExress, SQL Express, and ASP.NET
Arvixe -- My favored web host- Marked As Answer by Hagman42 Thursday, November 15, 2012 7:55 PM
-
Thursday, November 15, 2012 7:57 PM
Hi,
Absolutely correct. I simply did not think that would be the issue but it was. Thank you for your prompt response!
:)

