Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Insert Command Help...Please

Reply
 
Old 06-18-2008   #1 (permalink)
Michael


 
 

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.FormViewInsertedEventArgs)


'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" /
Quote:

>
<asp:Parameter Name="original_Scale1" Type="Single" /
Quote:

>
<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" /
Quote:

>
<asp:Parameter Name="original_Scale1" Type="Single" /
Quote:

>
<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>


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Running a command from inside a script, command line is corrupted PowerShell
What is the command line command for unzipping files? Vista General
Solved Make a command prompt run a command as soon as it opens? General Discussion
Command Line Ren (Rename) command broken? Vista General
CD Insert/Jewel Case Insert Maker ignored? Vista music pictures video


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46