Insert Command Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bgreer5050

    Insert Command Help

    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.dt d">

    <script runat="server">




    Protected Sub FormView1_ItemI nserted1(ByVal sender As Object,
    ByVal e As System.Web.UI.W ebControls.Form ViewInsertedEve ntArgs)

    'Sub EmployeeFormVie w_ItemInserted( ByVal sender As Object,
    ByVal e As FormViewInserte dEventArgs)

    ' 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.Redire ct("scrapredire ct.aspx")

    Else

    MsgBox("WARNING --- DATA NOT RECORDED --- SERVER
    ERROR")

    ' Use the KeepInInsertMod e property to remain in
    insert mode
    ' when an error occurs during the insert operation.
    e.KeepInInsertM ode = True

    End If

    Else

    ' Insert the code to handle the exception.
    MsgBox("WARNING --- DATA NOT RECORDED --- SERVER ERROR")

    ' Use the ExceptionHandle d property to indicate that the
    ' exception has already been handled.
    e.ExceptionHand led = True
    e.KeepInInsertM ode = True

    End If
    End Sub
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Scrap Trailer</title>
    </head>
    <body bgcolor="#ccccc c">
    <form id="form1" runat="server">
    <div style="text-align: left">
    <asp:FormView ID="FormView1" runat="server" DataKeyNames="I D"
    DataSourceID="A ccessDataSource 1"
    DefaultMode="In sert" Style="z-index: 100; left: 28px;
    position: absolute; top: 210px" Width="240px"
    OnItemInserted= "FormView1_Item Inserted1">
    <EditItemTempla te>
    ID:
    <asp:Label ID="IDLabel1" runat="server" Text='<%#
    Eval("ID") %>'></asp:Label><br />
    Scale1:
    <asp:TextBox ID="Scale1TextB ox" runat="server" Text='<
    %# Bind("Scale1") %>'>
    </asp:TextBox><br />
    Scale2:
    <asp:TextBox ID="Scale2TextB ox" runat="server" Text='<
    %# Bind("Scale2") %>'>
    </asp:TextBox><br />
    Employee:
    <asp:TextBox ID="EmployeeTex tBox" runat="server"
    Text='<%# Bind("Employee" ) %>'>
    </asp:TextBox><br />
    <asp:LinkButt on ID="UpdateButto n" runat="server"
    CausesValidatio n="True" CommandName="Up date"
    Text="Update">
    </asp:LinkButton>
    <asp:LinkButt on ID="UpdateCance lButton" runat="server"
    CausesValidatio n="False" CommandName="Ca ncel"
    Text="Cancel">
    </asp:LinkButton>
    </EditItemTemplat e>
    <InsertItemTemp late>
    Scale1:
    <asp:TextBox ID="Scale1TextB ox" runat="server" Text='<
    %# Bind("Scale1") %>'>
    </asp:TextBox><br />
    Scale2:
    <asp:TextBox ID="Scale2TextB ox" runat="server" Text='<
    %# Bind("Scale2") %>'>
    </asp:TextBox><br />
    Employee:
    <asp:TextBox ID="EmployeeTex tBox" 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:LinkButt on ID="InsertButto n" runat="server"
    CausesValidatio n="True" CommandName="In sert"
    Text="Record"></asp:LinkButton>
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp;<br />
    <br />
    &nbsp;<asp:Link Button ID="InsertCance lButton"
    runat="server" CausesValidatio n="False" CommandName="Ca ncel"
    Text="Cancel">
    </asp:LinkButton>
    </InsertItemTempl ate>
    <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="EmployeeLab el" runat="server" Text='<%#
    Bind("Employee" ) %>'></asp:Label><br />
    <asp:LinkButt on ID="EditButton " runat="server"
    CausesValidatio n="False" CommandName="Ed it"
    Text="Edit">
    </asp:LinkButton>
    <asp:LinkButt on ID="DeleteButto n" runat="server"
    CausesValidatio n="False" CommandName="De lete"
    Text="Delete">
    </asp:LinkButton>
    <asp:LinkButt on ID="NewButton" runat="server"
    CausesValidatio n="False" CommandName="Ne w"
    Text="New">
    </asp:LinkButton>
    </ItemTemplate>
    </asp:FormView>
    <br />
    <span style="font-size: 48pt">Scrap Data Entry&nbsp;</
    span><asp:Acces sDataSource ID="AccessDataS ource1" runat="server"
    ConflictDetecti on="CompareAllV alues"
    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())"
    OldValuesParame terFormatString ="original_{ 0}"
    SelectCommand=" SELECT * FROM [Scrap]"
    UpdateCommand=" UPDATE [Scrap] SET [Scale1] = ?, [Scale2]
    = ?, [Employee] = ? WHERE [ID] = ? AND [Scale1] = ? AND [Scale2] = ?
    AND [Employee] = ?">
    <DeleteParamete rs>
    <asp:Paramete r Name="original_ ID" Type="Int32" />
    <asp:Paramete r Name="original_ Employee" Type="String" /
    >
    <asp:Paramete r Name="original_ Scale2" Type="Single" />
    <asp:Paramete r Name="original_ Scale1" Type="Single" />
    <asp:Paramete r Name="original_ Date" Type="String" />
    </DeleteParameter s>
    <UpdateParamete rs>
    <asp:Paramete r Name="Employee" Type="String" />
    <asp:Paramete r Name="Scale2" Type="Single" />
    <asp:Paramete r Name="Scale1" Type="Single" />
    <asp:Paramete r Name="Date" Type="String" />
    <asp:Paramete r Name="original_ ID" Type="Int32" />
    <asp:Paramete r Name="original_ Employee" Type="String" /
    >
    <asp:Paramete r Name="original_ Scale2" Type="Single" />
    <asp:Paramete r Name="original_ Scale1" Type="Single" />
    <asp:Paramete r Name="original_ Date" Type="String" />
    </UpdateParameter s>
    <InsertParamete rs>
    <asp:Paramete r Name="Employee" Type="String" />
    <asp:Paramete r Name="Scale2" Type="Single" />
    <asp:Paramete r Name="Scale1" Type="Single" />
    <asp:Paramete r Name="Date" Type="DateTime" />
    <asp:Paramete r Name="ID" Type="Int32" />

    </InsertParameter s>
    </asp:AccessDataS ource>
    &nbsp;

    </div>
    </form>
    </body>
    </html>
Working...