472,978 Members | 2,406 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,978 software developers and data experts.

Insert Command Help...Please

I know I am missing something simple, but I am stuck. When I submit
the following for the employee info gets stored in scale1 and scale1
shows the employee number. Can someone show me my mistake. Thanks.

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">
Protected Sub FormView1_ItemInserted1(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.FormViewInsertedEventArg s)
'Sub EmployeeFormView_ItemInserted(ByVal sender As Object,
ByVal e As FormViewInsertedEventArgs)
' Use the Exception property to determine whether an
exception
' occurred during the insert operation.
If e.Exception Is Nothing Then
' Use the AffectedRows property to determine whether the
' record was inserted. Sometimes an error might occur
that
' does not raise an exception, but prevents the insert
' operation from completing.
If e.AffectedRows = 1 Then
'MsgBox("Data Recorded")
Response.Redirect("scrapredirect.aspx")
Else
MsgBox("WARNING --- DATA NOT RECORDED --- SERVER
ERROR")
' Use the KeepInInsertMode property to remain in
insert mode
' when an error occurs during the insert operation.
e.KeepInInsertMode = True
End If
Else
' Insert the code to handle the exception.
MsgBox("WARNING --- DATA NOT RECORDED --- SERVER ERROR")
' Use the ExceptionHandled property to indicate that the
' exception has already been handled.
e.ExceptionHandled = True
e.KeepInInsertMode = True
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Scrap Trailer</title>
</head>
<body bgcolor="#cccccc">
<form id="form1" runat="server">
<div style="text-align: left">
<asp:FormView ID="FormView1" runat="server" DataKeyNames="ID"
DataSourceID="AccessDataSource1"
DefaultMode="Insert" Style="z-index: 100; left: 28px;
position: absolute; top: 210px" Width="240px"
OnItemInserted="FormView1_ItemInserted1">
<EditItemTemplate>
ID:
<asp:Label ID="IDLabel1" runat="server" Text='<%#
Eval("ID") %>'></asp:Label><br />
Scale1:
<asp:TextBox ID="Scale1TextBox" runat="server"
Text='<
%# Bind("Scale1") %>'>
</asp:TextBox><br />
Scale2:
<asp:TextBox ID="Scale2TextBox" runat="server"
Text='<
%# Bind("Scale2") %>'>
</asp:TextBox><br />
Employee:
<asp:TextBox ID="EmployeeTextBox" runat="server"
Text='<%# Bind("Employee") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True" CommandName="Update"
Text="Update">
</asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton"
runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>
Scale1:
<asp:TextBox ID="Scale1TextBox" runat="server"
Text='<
%# Bind("Scale1") %>'>
</asp:TextBox><br />
Scale2:
<asp:TextBox ID="Scale2TextBox" runat="server"
Text='<
%# Bind("Scale2") %>'>
</asp:TextBox><br />
Employee:
<asp:TextBox ID="EmployeeTextBox" runat="server"
Text='<%# Bind("Employee") %>'></asp:TextBox><br />
<br />
Date:
<asp:TextBox ID="DateTextBox" runat="server" Text='<
%#
Bind("Date") %>' Visible="False"></asp:TextBox><br />
<br />
<asp:LinkButton ID="InsertButton" runat="server"
CausesValidation="True" CommandName="Insert"
Text="Record"></asp:LinkButton>

<br />
<br />
<asp:LinkButton ID="InsertCancelButton"
runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
ID:
<asp:Label ID="IDLabel" runat="server" Text='<%#
Eval("ID") %>'></asp:Label><br />
Scale1:
<asp:Label ID="Scale1Label" runat="server" Text='<%#
Bind("Scale1") %>'></asp:Label><br />
Scale2:
<asp:Label ID="Scale2Label" runat="server" Text='<%#
Bind("Scale2") %>'></asp:Label><br />
Employee:
<asp:Label ID="EmployeeLabel" runat="server" Text='<
%#
Bind("Employee") %>'></asp:Label><br />
<asp:LinkButton ID="EditButton" runat="server"
CausesValidation="False" CommandName="Edit"
Text="Edit">
</asp:LinkButton>
<asp:LinkButton ID="DeleteButton" runat="server"
CausesValidation="False" CommandName="Delete"
Text="Delete">
</asp:LinkButton>
<asp:LinkButton ID="NewButton" runat="server"
CausesValidation="False" CommandName="New"
Text="New">
</asp:LinkButton>
</ItemTemplate>
</asp:FormView>
<br />
<span style="font-size: 48pt">Scrap Data Entry </
span><asp:AccessDataSource ID="AccessDataSource1" runat="server"
ConflictDetection="CompareAllValues"
DataFile="~/App_Data/Spare_Parts_II_BCPC.mdb"
DeleteCommand="DELETE FROM [Scrap] WHERE [ID] = ? AND [Scale1] = ?
AND
[Scale2] = ? AND [Employee] = ?"
InsertCommand="INSERT INTO [Scrap] ([Scale1], [Scale2],
[Employee],[Date]) VALUES (?, ?, ?,now())"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [Scrap]"
UpdateCommand="UPDATE [Scrap] SET [Scale1] = ?, [Scale2]
= ?, [Employee] = ? WHERE [ID] = ? AND [Scale1] = ? AND [Scale2] = ?
AND [Employee] = ?">
<DeleteParameters>
<asp:Parameter Name="original_ID" Type="Int32" />
<asp:Parameter Name="original_Employee"
Type="String" /


<asp:Parameter Name="original_Scale2" Type="Single" /
>
<asp:Parameter Name="original_Scale1" Type="Single" /
>
<asp:Parameter Name="original_Date" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Employee" Type="String" />
<asp:Parameter Name="Scale2" Type="Single" />
<asp:Parameter Name="Scale1" Type="Single" />
<asp:Parameter Name="Date" Type="String" />
<asp:Parameter Name="original_ID" Type="Int32" />
<asp:Parameter Name="original_Employee"
Type="String" /

<asp:Parameter Name="original_Scale2" Type="Single" /
>
<asp:Parameter Name="original_Scale1" Type="Single" /
>
<asp:Parameter Name="original_Date" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Employee" Type="String" />
<asp:Parameter Name="Scale2" Type="Single" />
<asp:Parameter Name="Scale1" Type="Single" />
<asp:Parameter Name="Date" Type="DateTime" />
<asp:Parameter Name="ID" Type="Int32" />

</InsertParameters>
</asp:AccessDataSource>

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

Jun 27 '08 #1
0 1272

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: george | last post by:
This is like the bug from hell. It is kind of hard to explain, so please bear with me. Background Info: SQL Server 7.0, on an NT box, Active Server pages with Javascript, using ADO objects. ...
3
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all...
4
by: Mark Olbert | last post by:
I am struggling with trying to retrieve the value of an autoincrement identity field after a DetailsView Insert operation. The DetailsView is bound to an SqlDataSource control. So far as I can...
1
by: sheenaa | last post by:
Hello Members, I m creating my application forms in ASP.Net 2005 C# using the backend SQL Server 2005. What i have used on forms :: ? On my first form i have used some...
2
by: sangam56 | last post by:
Greetings. I suppose people out there can help in my problem. I am using sql server of microsoft visual studio 2005 itself. I have created a stored procedure which is give below. It works fine but...
5
by: =?Utf-8?B?bXBhaW5l?= | last post by:
Hello, I am completely lost as to why I can't update a DropDownList inside a DetailsView after I perform an insert into an object datasource. I tried to simply it down to the core demostration:...
2
by: paulmitchell507 | last post by:
I think I am attempting a simple procedure but I just can't figure out the correct syntax. My asp (classic) page runs a SELECT query to obtain dates and ID's from 2 tables uSQL = "SELECT...
7
by: anu b | last post by:
Hi I need to use Clr trigger for insert command My code is as below I am using SQL server 2005 and VS 2008.... but after running this code i didnt get the result as i expexted it shows the...
1
by: gilesy | last post by:
Hi, I have a ploblem with an insert statement using an access database, I have the same code with a sql database which works but it doesn't seem to work on access. Could someone please help. For...
3
by: gilesy | last post by:
Hi, I have a ploblem with an insert statement using an access database, I have the same code with a sql database which works but it doesn't seem to work on access. Could someone please help. For i =...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.