I have the following code:
and I'm trying to use that to submit to my database, but when I click on the submit button, no data is being inserted into my database, but I'm also not receiving any errors. Can someone maybe point out why?
Thank you
Doug
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>Untitled Page</title> <style type="text/css"> #Submit1 { width: 131px; } .style1 { color: #FF0000; } </style> <script language="javascript" type="text/javascript"> // <!CDATA[ function Submit1_onclick() { Dim connectionString As String Dim cnn As SqlConnection Dim myCommand As SqlCommand Dim dteReturnValue As DateTime = Nothing 'the connection string to the SQL server' connectionString = "Data Source=10.2.1.41;Initial Catalog=MDR;uid=xxxxx;password=xxxxxxx" cnn = New SqlConnection(connectionString) cnn.Open() myCommand.CommandText = "insert into Exceptions2 values('" & exceptiondateInput.Text & "','" & starttimeInput.Text & "','" & txtAddress.Text & "','" & endtimeInput.Text & "','" & duration.text & "')" myCommand.Connection = con con.Open() myCommand.ExecuteNonQuery() con.Close() } // ]]> </script> </head> <body> <br /> <form id="form1" runat="server"> <div align="left"> <asp:DropDownList ID="OperatorDropdown" runat="server" DataSourceID="SqlDataSource1" DataTextField="employeenumber" DataValueField="employeenumber" Height="23px" Width="130px"> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MDRConnectionString %>" SelectCommand="SELECT [employeenumber] FROM [Employees]"> </asp:SqlDataSource> Choose an Operator <br /> <br /> <br /> <asp:TextBox ID="exceptiondateInput" runat="server" Width="130px" Height="23px"></asp:TextBox> <span class="style1">*</span> Exception Date <asp:RegularExpressionValidator ID="DateValidator" runat="server" ControlToValidate="exceptiondateInput" ValidationExpression="^\d{1,2}\/\d{1,2}\/\d{4}$" ErrorMessage="Please Enter the Date Correctly"></asp:RegularExpressionValidator> <br /> <br /> <br /> <asp:TextBox ID="starttimeInput" runat="server" Width="130px" Height="23px"></asp:TextBox> <span class="style1">*</span> Start Time <asp:RegularExpressionValidator ValidationExpression="^([0-1][0-9]|[2][0-3]):([0-5][0-9])$" ID="StartTimeValidator" runat="server" ErrorMessage="You Must Supply an Start Time" ControlToValidate="starttimeInput"></asp:RegularExpressionValidator><br /> <br /> <br /> <asp:TextBox ID="endtimeInput" runat="server" Width="130px" Height="23px"></asp:TextBox> <span class="style1">*</span> End Time <asp:RegularExpressionValidator ID="EndTimeValidator" runat="server" ValidationExpression="^([0-1][0-9]|[2][0-3]):([0-5][0-9])$" ErrorMessage="You Must Supply an End Time" ControlToValidate="endtimeInput"></asp:RegularExpressionValidator> <br /> <br /> <br /> <asp:TextBox ID="durationInput" runat="server" Width="130px" Height="23px"></asp:TextBox> <span class="style1">*</span> Duration <asp:RequiredFieldValidator ID="DurationValidator" runat="server" ErrorMessage="Exception Duration Must Be Entered" ControlToValidate="durationInput"></asp:RequiredFieldValidator> <br /> <br /> <br /> <asp:DropDownList ID="Reason" runat="server" Height="23px" Width="206px"> <asp:ListItem Value="NoSelection">--- No Selection --</asp:ListItem> <asp:ListItem>1. Approved Technical Reason</asp:ListItem> <asp:ListItem>2. Coaching Session</asp:ListItem> <asp:ListItem>3. ETO</asp:ListItem> <asp:ListItem>4. Sick Leave</asp:ListItem> <asp:ListItem>5. Special Project</asp:ListItem> <asp:ListItem>6. Supervisor Meeting</asp:ListItem> <asp:ListItem>7. Vacation</asp:ListItem> </asp:DropDownList> Choose a reason for exception <asp:compareValidator id="reasonValidator" runat="server" ControlToValidate="Reason" ValueToCompare="NoSelection" Operator="NotEqual" ErrorMessage="Please Select an item" /> <br /> <br /> <br /> <asp:DropDownList ID="Approved" runat="server" Width="130px" Height="23px"> <asp:ListItem Value="NoSelection">--- No Selection --</asp:ListItem> <asp:ListItem>Patrice Paul</asp:ListItem> <asp:ListItem>Zach Cochran</asp:ListItem> </asp:DropDownList> Approved By <asp:compareValidator id="CompareValidator1" runat="server" ControlToValidate="Approved" ValueToCompare="NoSelection" Operator="NotEqual" ErrorMessage="Please Select an item" /> <br /> <br /> <br /> <input id="Submit1" type="submit" value="Submit" onclick="return Submit1_onclick()" /><br /> <br /> <br /> <span class="style1">* all fields with asterisks must be filled out</span><br /> </div> </form> </body> </html>
Thank you
Doug
Comment