I am using Microsoft VWD 2008 express edition. I have linked an Access 2007 database to my asp.net application using a gridview control. On the webpage are four text boxes allowing a user to input (first name, last name, donation amount and date).
After the user inputs the values, I want them to click the "Submit" button and have that information from the text boxes write to the Access 2007 database.
This is where my problem lies. I hit a mental blank when I begin to program the button. Not sure where to start. Any help is appreciated! Thanks. ~Mike
My code is below:
After the user inputs the values, I want them to click the "Submit" button and have that information from the text boxes write to the Access 2007 database.
This is where my problem lies. I hit a mental blank when I begin to program the button. Not sure where to start. Any help is appreciated! Thanks. ~Mike
My code is below:
Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<p>
First Name:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</p>
<p>
</p>
<p>
Last Name:
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</p>
<p>
</p>
<p>
Donation:
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</p>
<p>
</p>
<p>
Donation Date:
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</p>
<p>
</p>
<p>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" style="height: 26px" />
</p>
<p>
</p>
<p>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
DeleteCommand="DELETE FROM [Table1] WHERE (([Last Name] = ?) OR ([Last Name] IS NULL AND ? IS NULL)) AND [ID] = ? AND (([First Name] = ?) OR ([First Name] IS NULL AND ? IS NULL)) AND (([Donation Amount] = ?) OR ([Donation Amount] IS NULL AND ? IS NULL)) AND (([Date of Donation] = ?) OR ([Date of Donation] IS NULL AND ? IS NULL))"
InsertCommand="INSERT INTO [Table1] ([ID], [First Name], [Last Name], [Donation Amount], [Date of Donation]) VALUES (?, ?, ?, ?, ?)"
OldValuesParameterFormatString="original_{0}"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT * FROM [Table1]"
UpdateCommand="UPDATE [Table1] SET [ID] = ?, [First Name] = ?, [Donation Amount] = ?, [Date of Donation] = ? WHERE (([Last Name] = ?) OR ([Last Name] IS NULL AND ? IS NULL)) AND [ID] = ? AND (([First Name] = ?) OR ([First Name] IS NULL AND ? IS NULL)) AND (([Donation Amount] = ?) OR ([Donation Amount] IS NULL AND ? IS NULL)) AND (([Date of Donation] = ?) OR ([Date of Donation] IS NULL AND ? IS NULL))">
<DeleteParameters>
<asp:Parameter Name="original_Last_Name" Type="String" />
<asp:Parameter Name="original_ID" Type="Int32" />
<asp:Parameter Name="original_First_Name" Type="String" />
<asp:Parameter Name="original_Donation_Amount" Type="Decimal" />
<asp:Parameter Name="original_Date_of_Donation" Type="DateTime" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="First_Name" Type="String" />
<asp:Parameter Name="Donation_Amount" Type="Decimal" />
<asp:Parameter Name="Date_of_Donation" Type="DateTime" />
<asp:Parameter Name="original_Last_Name" Type="String" />
<asp:Parameter Name="original_ID" Type="Int32" />
<asp:Parameter Name="original_First_Name" Type="String" />
<asp:Parameter Name="original_Donation_Amount" Type="Decimal" />
<asp:Parameter Name="original_Date_of_Donation" Type="DateTime" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="First_Name" Type="String" />
<asp:Parameter Name="Last_Name" Type="String" />
<asp:Parameter Name="Donation_Amount" Type="Decimal" />
<asp:Parameter Name="Date_of_Donation" Type="DateTime" />
</InsertParameters>
</asp:SqlDataSource>
</p>
<p>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="Last Name" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
SortExpression="ID" />
<asp:BoundField DataField="First Name" HeaderText="First Name"
SortExpression="First Name" />
<asp:BoundField DataField="Last Name" HeaderText="Last Name" ReadOnly="True"
SortExpression="Last Name" />
<asp:BoundField DataField="Donation Amount" HeaderText="Donation Amount"
SortExpression="Donation Amount" />
<asp:BoundField DataField="Date of Donation" HeaderText="Date of Donation"
SortExpression="Date of Donation" />
</Columns>
</asp:GridView>
</p>
<p>
</p>
<p>
</p>
<div>
</div>
</form>
</body>
</html>
Comment