ASP script does not update Access Database

W

webby

I have created a ASP script using Microsoft Visual Web Developer Express
Edition 2005 that will enable users to edit a Access database in a gridview.
The script functions without any errors and allows you to edit the fields but
when you press the update button the page refreshes and the changes are lost.
I have triple checked the perms n(IUSR and IWAM) on the access db, the aspx
page and the folders and they appear correct. This is running on Windows XP
Pro with IIS for dev purposes only, after it workes correctly I will transfer
it to W2003 Server. Here is the code:


<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" CellPadding="4"
DataKeyNames="AutoNumber" DataSourceID="AccessDataSource7"
ForeColor="#333333"
GridLines="None" Height="216px" Style="z-index: 100; left: 10px;
position: absolute;
top: 121px" Width="359px">
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<Columns>
<asp:CommandField ShowDeleteButton="True"
ShowEditButton="True" ShowSelectButton="True" />
<asp:BoundField DataField="AutoNumber"
HeaderText="AutoNumber" InsertVisible="False"
ReadOnly="True" SortExpression="AutoNumber" />
<asp:BoundField DataField="LastName" HeaderText="LastName"
SortExpression="LastName" />
<asp:BoundField DataField="Soundex" HeaderText="Soundex"
SortExpression="Soundex" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName"
SortExpression="FirstName" />
<asp:BoundField DataField="MiddleInitial"
HeaderText="MiddleInitial" SortExpression="MiddleInitial" />
<asp:BoundField DataField="CaseNumber"
HeaderText="CaseNumber" SortExpression="CaseNumber" />
<asp:BoundField DataField="DOB" HeaderText="DOB"
SortExpression="DOB" />
<asp:BoundField DataField="Race" HeaderText="Race"
SortExpression="Race" />
<asp:BoundField DataField="Sex" HeaderText="Sex"
SortExpression="Sex" />
<asp:BoundField DataField="Address" HeaderText="Address"
SortExpression="Address" />
<asp:CheckBoxField DataField="PublicHousing"
HeaderText="PublicHousing" SortExpression="PublicHousing" />
<asp:BoundField DataField="Date" HeaderText="Date"
SortExpression="Date" />
<asp:BoundField DataField="Length" HeaderText="Length"
SortExpression="Length" />
<asp:BoundField DataField="EmpLastName"
HeaderText="EmpLastName" SortExpression="EmpLastName" />
<asp:BoundField DataField="EmpfirstName"
HeaderText="EmpfirstName" SortExpression="EmpfirstName" />
</Columns>
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource7" runat="server"
ConflictDetection="CompareAllValues"
DataFile="C:\Inetpub\wwwroot\db\VBTEST.mdb"
DeleteCommand="DELETE FROM [Trespass] WHERE [AutoNumber] = ? AND [LastName] =
? AND [Soundex] = ? AND [FirstName] = ? AND [MiddleInitial] = ? AND
[CaseNumber] = ? AND [DOB] = ? AND [Race] = ? AND [Sex] = ? AND [Address] = ?
AND [PublicHousing] = ? AND [Date] = ? AND [Length] = ? AND [EmpLastName] = ?
AND [EmpfirstName] = ?"
InsertCommand="INSERT INTO [Trespass] ([AutoNumber], [LastName],
[Soundex], [FirstName], [MiddleInitial], [CaseNumber], [DOB], [Race], [Sex],
[Address], [PublicHousing], [Date], [Length], [EmpLastName], [EmpfirstName])
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [Trespass]"
UpdateCommand="UPDATE [Trespass] SET [LastName] = ?, [Soundex] =
?, [FirstName] = ?, [MiddleInitial] = ?, [CaseNumber] = ?, [DOB] = ?, [Race]
= ?, [Sex] = ?, [Address] = ?, [PublicHousing] = ?, [Date] = ?, [Length] = ?,
[EmpLastName] = ?, [EmpfirstName] = ? WHERE [AutoNumber] = ? AND [LastName] =
? AND [Soundex] = ? AND [FirstName] = ? AND [MiddleInitial] = ? AND
[CaseNumber] = ? AND [DOB] = ? AND [Race] = ? AND [Sex] = ? AND [Address] = ?
AND [PublicHousing] = ? AND [Date] = ? AND [Length] = ? AND [EmpLastName] = ?
AND [EmpfirstName] = ?">
<DeleteParameters>
<asp:parameter Name="original_AutoNumber" Type="Int32" />
<asp:parameter Name="original_LastName" Type="String" />
<asp:parameter Name="original_Soundex" Type="String" />
<asp:parameter Name="original_FirstName" Type="String" />
<asp:parameter Name="original_MiddleInitial" Type="String" />
<asp:parameter Name="original_CaseNumber" Type="Int32" />
<asp:parameter Name="original_DOB" Type="String" />
<asp:parameter Name="original_Race" Type="String" />
<asp:parameter Name="original_Sex" Type="String" />
<asp:parameter Name="original_Address" Type="String" />
<asp:parameter Name="original_PublicHousing" Type="Boolean" />
<asp:parameter Name="original_Date" Type="DateTime" />
<asp:parameter Name="original_Length" Type="String" />
<asp:parameter Name="original_EmpLastName" Type="String" />
<asp:parameter Name="original_EmpfirstName" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:parameter Name="LastName" Type="String" />
<asp:parameter Name="Soundex" Type="String" />
<asp:parameter Name="FirstName" Type="String" />
<asp:parameter Name="MiddleInitial" Type="String" />
<asp:parameter Name="CaseNumber" Type="Int32" />
<asp:parameter Name="DOB" Type="String" />
<asp:parameter Name="Race" Type="String" />
<asp:parameter Name="Sex" Type="String" />
<asp:parameter Name="Address" Type="String" />
<asp:parameter Name="PublicHousing" Type="Boolean" />
<asp:parameter Name="Date" Type="DateTime" />
<asp:parameter Name="Length" Type="String" />
<asp:parameter Name="EmpLastName" Type="String" />
<asp:parameter Name="EmpfirstName" Type="String" />
<asp:parameter Name="original_AutoNumber" Type="Int32" />
<asp:parameter Name="original_LastName" Type="String" />
<asp:parameter Name="original_Soundex" Type="String" />
<asp:parameter Name="original_FirstName" Type="String" />
<asp:parameter Name="original_MiddleInitial" Type="String" />
<asp:parameter Name="original_CaseNumber" Type="Int32" />
<asp:parameter Name="original_DOB" Type="String" />
<asp:parameter Name="original_Race" Type="String" />
<asp:parameter Name="original_Sex" Type="String" />
<asp:parameter Name="original_Address" Type="String" />
<asp:parameter Name="original_PublicHousing" Type="Boolean" />
<asp:parameter Name="original_Date" Type="DateTime" />
<asp:parameter Name="original_Length" Type="String" />
<asp:parameter Name="original_EmpLastName" Type="String" />
<asp:parameter Name="original_EmpfirstName" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:parameter Name="AutoNumber" Type="Int32" />
<asp:parameter Name="LastName" Type="String" />
<asp:parameter Name="Soundex" Type="String" />
<asp:parameter Name="FirstName" Type="String" />
<asp:parameter Name="MiddleInitial" Type="String" />
<asp:parameter Name="CaseNumber" Type="Int32" />
<asp:parameter Name="DOB" Type="String" />
<asp:parameter Name="Race" Type="String" />
<asp:parameter Name="Sex" Type="String" />
<asp:parameter Name="Address" Type="String" />
<asp:parameter Name="PublicHousing" Type="Boolean" />
<asp:parameter Name="Date" Type="DateTime" />
<asp:parameter Name="Length" Type="String" />
<asp:parameter Name="EmpLastName" Type="String" />
<asp:parameter Name="EmpfirstName" Type="String" />
</InsertParameters>
</asp:AccessDataSource>


</div>
</form>
</body>
</html>

Any help with this would be great. Thanks.
 
B

Brendan Reynolds

a) It is unlikely that this is an Access issue, it is probably an ADO.NET or
ASP.NET issue.

b) I don't think the problem lies anywhere in the HTML that you posted, more
likely it lies in the VB.NET code that you did not post, probably in the
Click event procedure of the command button.

--
Brendan Reynolds
Access MVP

webby said:
I have created a ASP script using Microsoft Visual Web Developer Express
Edition 2005 that will enable users to edit a Access database in a
gridview.
The script functions without any errors and allows you to edit the fields
but
when you press the update button the page refreshes and the changes are
lost.
I have triple checked the perms n(IUSR and IWAM) on the access db, the
aspx
page and the folders and they appear correct. This is running on Windows
XP
Pro with IIS for dev purposes only, after it workes correctly I will
transfer
it to W2003 Server. Here is the code:


<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" CellPadding="4"
DataKeyNames="AutoNumber" DataSourceID="AccessDataSource7"
ForeColor="#333333"
GridLines="None" Height="216px" Style="z-index: 100; left:
10px;
position: absolute;
top: 121px" Width="359px">
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<Columns>
<asp:CommandField ShowDeleteButton="True"
ShowEditButton="True" ShowSelectButton="True" />
<asp:BoundField DataField="AutoNumber"
HeaderText="AutoNumber" InsertVisible="False"
ReadOnly="True" SortExpression="AutoNumber" />
<asp:BoundField DataField="LastName" HeaderText="LastName"
SortExpression="LastName" />
<asp:BoundField DataField="Soundex" HeaderText="Soundex"
SortExpression="Soundex" />
<asp:BoundField DataField="FirstName"
HeaderText="FirstName"
SortExpression="FirstName" />
<asp:BoundField DataField="MiddleInitial"
HeaderText="MiddleInitial" SortExpression="MiddleInitial" />
<asp:BoundField DataField="CaseNumber"
HeaderText="CaseNumber" SortExpression="CaseNumber" />
<asp:BoundField DataField="DOB" HeaderText="DOB"
SortExpression="DOB" />
<asp:BoundField DataField="Race" HeaderText="Race"
SortExpression="Race" />
<asp:BoundField DataField="Sex" HeaderText="Sex"
SortExpression="Sex" />
<asp:BoundField DataField="Address" HeaderText="Address"
SortExpression="Address" />
<asp:CheckBoxField DataField="PublicHousing"
HeaderText="PublicHousing" SortExpression="PublicHousing" />
<asp:BoundField DataField="Date" HeaderText="Date"
SortExpression="Date" />
<asp:BoundField DataField="Length" HeaderText="Length"
SortExpression="Length" />
<asp:BoundField DataField="EmpLastName"
HeaderText="EmpLastName" SortExpression="EmpLastName" />
<asp:BoundField DataField="EmpfirstName"
HeaderText="EmpfirstName" SortExpression="EmpfirstName" />
</Columns>
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource7" runat="server"
ConflictDetection="CompareAllValues"
DataFile="C:\Inetpub\wwwroot\db\VBTEST.mdb"
DeleteCommand="DELETE FROM [Trespass] WHERE [AutoNumber] = ? AND
[LastName] =
? AND [Soundex] = ? AND [FirstName] = ? AND [MiddleInitial] = ? AND
[CaseNumber] = ? AND [DOB] = ? AND [Race] = ? AND [Sex] = ? AND [Address]
= ?
AND [PublicHousing] = ? AND [Date] = ? AND [Length] = ? AND [EmpLastName]
= ?
AND [EmpfirstName] = ?"
InsertCommand="INSERT INTO [Trespass] ([AutoNumber],
[LastName],
[Soundex], [FirstName], [MiddleInitial], [CaseNumber], [DOB], [Race],
[Sex],
[Address], [PublicHousing], [Date], [Length], [EmpLastName],
[EmpfirstName])
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [Trespass]"
UpdateCommand="UPDATE [Trespass] SET [LastName] = ?, [Soundex]
=
?, [FirstName] = ?, [MiddleInitial] = ?, [CaseNumber] = ?, [DOB] = ?,
[Race]
= ?, [Sex] = ?, [Address] = ?, [PublicHousing] = ?, [Date] = ?, [Length] =
?,
[EmpLastName] = ?, [EmpfirstName] = ? WHERE [AutoNumber] = ? AND
[LastName] =
? AND [Soundex] = ? AND [FirstName] = ? AND [MiddleInitial] = ? AND
[CaseNumber] = ? AND [DOB] = ? AND [Race] = ? AND [Sex] = ? AND [Address]
= ?
AND [PublicHousing] = ? AND [Date] = ? AND [Length] = ? AND [EmpLastName]
= ?
AND [EmpfirstName] = ?">
<DeleteParameters>
<asp:parameter Name="original_AutoNumber" Type="Int32" />
<asp:parameter Name="original_LastName" Type="String" />
<asp:parameter Name="original_Soundex" Type="String" />
<asp:parameter Name="original_FirstName" Type="String" />
<asp:parameter Name="original_MiddleInitial" Type="String"
/>
<asp:parameter Name="original_CaseNumber" Type="Int32" />
<asp:parameter Name="original_DOB" Type="String" />
<asp:parameter Name="original_Race" Type="String" />
<asp:parameter Name="original_Sex" Type="String" />
<asp:parameter Name="original_Address" Type="String" />
<asp:parameter Name="original_PublicHousing" Type="Boolean"
/>
<asp:parameter Name="original_Date" Type="DateTime" />
<asp:parameter Name="original_Length" Type="String" />
<asp:parameter Name="original_EmpLastName" Type="String" />
<asp:parameter Name="original_EmpfirstName" Type="String"
/>
</DeleteParameters>
<UpdateParameters>
<asp:parameter Name="LastName" Type="String" />
<asp:parameter Name="Soundex" Type="String" />
<asp:parameter Name="FirstName" Type="String" />
<asp:parameter Name="MiddleInitial" Type="String" />
<asp:parameter Name="CaseNumber" Type="Int32" />
<asp:parameter Name="DOB" Type="String" />
<asp:parameter Name="Race" Type="String" />
<asp:parameter Name="Sex" Type="String" />
<asp:parameter Name="Address" Type="String" />
<asp:parameter Name="PublicHousing" Type="Boolean" />
<asp:parameter Name="Date" Type="DateTime" />
<asp:parameter Name="Length" Type="String" />
<asp:parameter Name="EmpLastName" Type="String" />
<asp:parameter Name="EmpfirstName" Type="String" />
<asp:parameter Name="original_AutoNumber" Type="Int32" />
<asp:parameter Name="original_LastName" Type="String" />
<asp:parameter Name="original_Soundex" Type="String" />
<asp:parameter Name="original_FirstName" Type="String" />
<asp:parameter Name="original_MiddleInitial" Type="String"
/>
<asp:parameter Name="original_CaseNumber" Type="Int32" />
<asp:parameter Name="original_DOB" Type="String" />
<asp:parameter Name="original_Race" Type="String" />
<asp:parameter Name="original_Sex" Type="String" />
<asp:parameter Name="original_Address" Type="String" />
<asp:parameter Name="original_PublicHousing" Type="Boolean"
/>
<asp:parameter Name="original_Date" Type="DateTime" />
<asp:parameter Name="original_Length" Type="String" />
<asp:parameter Name="original_EmpLastName" Type="String" />
<asp:parameter Name="original_EmpfirstName" Type="String"
/>
</UpdateParameters>
<InsertParameters>
<asp:parameter Name="AutoNumber" Type="Int32" />
<asp:parameter Name="LastName" Type="String" />
<asp:parameter Name="Soundex" Type="String" />
<asp:parameter Name="FirstName" Type="String" />
<asp:parameter Name="MiddleInitial" Type="String" />
<asp:parameter Name="CaseNumber" Type="Int32" />
<asp:parameter Name="DOB" Type="String" />
<asp:parameter Name="Race" Type="String" />
<asp:parameter Name="Sex" Type="String" />
<asp:parameter Name="Address" Type="String" />
<asp:parameter Name="PublicHousing" Type="Boolean" />
<asp:parameter Name="Date" Type="DateTime" />
<asp:parameter Name="Length" Type="String" />
<asp:parameter Name="EmpLastName" Type="String" />
<asp:parameter Name="EmpfirstName" Type="String" />
</InsertParameters>
</asp:AccessDataSource>


</div>
</form>
</body>
</html>

Any help with this would be great. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top