Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


SQL Command will not work

Posted on 2008-06-26
Medium Priority
Last Modified: 2013-11-06
I cannot figure out why my command will not work. It appears to me that everything is properly formatted. Can someone take a look at it and give suggestions?
<%@ Page Language="VB" MasterPageFile="~/_m/nonavbars.master" AutoEventWireup="false" CodeFile="jz_trucks.aspx.vb" Inherits="_a_jz_trucks" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphMain" Runat="Server">
        <h3>Juarez ICT Truck Shipments</h3>
        <h4>Add a new truck shipment</h4>
        Leave Date:&nbsp;<asp:textbox id="txtLveDate" runat="server" tabindex="1"></asp:textbox>&nbsp;
        <asp:imagebutton id="ibtnLveDate" runat="server" imageurl="~/_i/calendar.png" tabindex="2" />
        <asp:requiredfieldvalidator id="reqLveDate" runat="server" controltovalidate="txtLveDate"
            errormessage="*"></asp:requiredfieldvalidator><br />
        Arrive Date:&nbsp;<asp:textbox id="txtArvDate" runat="server" tabindex="3"></asp:textbox>&nbsp;
        <asp:imagebutton id="ibtnArvDate" runat="server" imageurl="~/_i/calendar.png" tabindex="4" />
        <asp:requiredfieldvalidator id="reqArvDate" runat="server" controltovalidate="txtArvDate"
            display="Dynamic" errormessage="*"></asp:requiredfieldvalidator><br />
        Initials:&nbsp;<asp:textbox id="txtInitials" runat="server" maxlength="3" tabindex="5"></asp:textbox>&nbsp;
        <asp:requiredfieldvalidator id="reqInitials" runat="server" controltovalidate="txtInitials"
            display="Dynamic" errormessage="*"></asp:requiredfieldvalidator><br />
        <asp:linkbutton id="lbtnJzTrkSubmit" runat="server" tabindex="6">Submit</asp:linkbutton>&nbsp;
        <asp:linkbutton id="lbtnJzTrkReset" runat="server" tabindex="7" causesvalidation="False">Reset</asp:linkbutton>&nbsp;
    <asp:label id="lblTruckSubmitted" runat="server" forecolor="#00C000" text="Truck shipment successfully submitted."
        visible="False"></asp:label><h4>Future Shipments</h4>
    <asp:gridview id="GridView1" runat="server" autogeneratecolumns="False" cellpadding="4" datasourceid="srcJzTrucks" emptydatatext="There are current no shipments scheduled." forecolor="#333333" gridlines="None">
        <footerstyle backcolor="#990000" font-bold="True" forecolor="White" />
        <rowstyle backcolor="#FFFBD6" forecolor="#333333" />
            <asp:boundfield datafield="leave_date" dataformatstring="(0:d}" headertext="Leaving"
                htmlencode="False" sortexpression="leave_date" />
            <asp:boundfield datafield="arrive_date" dataformatstring="(0:d}" headertext="Arriving"
                htmlencode="False" sortexpression="arrive_date" />
            <asp:boundfield datafield="initials" headertext="Submitted By" sortexpression="initials" />
            <asp:boundfield datafield="submit_date" dataformatstring="(0:d}" headertext="Submitted"
                htmlencodeformatstring="False" sortexpression="submit_date" />
        <pagerstyle backcolor="#FFCC66" forecolor="#333333" horizontalalign="Center" />
        <selectedrowstyle backcolor="#FFCC66" font-bold="True" forecolor="Navy" />
        <headerstyle backcolor="#990000" font-bold="True" forecolor="White" />
        <alternatingrowstyle backcolor="White" />
    <asp:sqldatasource id="srcJzTrucks" runat="server" connectionstring="<%$ ConnectionStrings:conIntranet %>"
        selectcommand="SELECT leave_date, arrive_date, initials, submit_date FROM jz_truck WHERE (arrive_date > { fn NOW() }) ORDER BY leave_date, arrive_date">
        <ajaxtoolkit:calendarextender id="calxLveDate" runat="server" popupbuttonid="ibtnLveDate" targetcontrolid="txtLveDate">
        <ajaxtoolkit:calendarextender id="calxArvDate" runat="server" popupbuttonid="ibtnArvDate" targetcontrolid="txtArvDate">
        <ajaxtoolkit:textboxwatermarkextender id="wtrLveDate" runat="server" targetcontrolid="txtLveDate" watermarktext="Enter leave date.">
        </ajaxtoolkit:textboxwatermarkextender><ajaxtoolkit:textboxwatermarkextender id="wtrArvDate" runat="server"  watermarktext="Enter arrive date."
        <ajaxtoolkit:textboxwatermarkextender id="wtrInitials" runat="server"  watermarktext="Enter initials."
        <ajaxtoolkit:maskededitextender id="meeLveDate" masktype="Date" mask="99/99/9999" runat="server" targetcontrolid="txtLveDate">
        <ajaxtoolkit:maskededitextender id="meeArvDate" masktype="Date" mask="99/99/9999" runat="server" targetcontrolid="txtArvDate">
Imports System.IO
Imports System.DateTime
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class _a_jz_trucks
    Inherits System.Web.UI.Page
    Protected Sub lbtnJzTrkReset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnJzTrkReset.Click
        Me.txtArvDate.Text = ""
        Me.txtInitials.Text = ""
        Me.txtLveDate.Text = ""
        Me.lblTruckSubmitted.Visible = False
    End Sub
    Protected Sub lbtnJzTrkSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnJzTrkSubmit.Click
        Dim dteLve As Date = Me.txtLveDate.Text
        Dim dteArv As Date = Me.txtArvDate.Text
        Dim dteSub As Date = Today.ToString()
        Dim strInitials As String = Me.txtInitials.Text
        Dim connectionString As String = WebConfigurationManager.ConnectionStrings("conIntranet").ConnectionString
        Dim con As New SqlConnection(connectionString)
        Dim cmdJzTruckInsert As New SqlCommand("INSERT jz_truck (leave_date, arrive_date, submit_date, initials) values (@LveDate, @ArvDate, @SubDate, @Initials)", con)
        cmdJzTruckInsert.Parameters.Add("@LveDate", SqlDbType.Date).Value = dteLve
        cmdJzTruckInsert.Parameters.Add("@ArvDate", SqlDbType.Date).Value = dteArv
        cmdJzTruckInsert.Parameters.Add("@SubDate", SqlDbType.Date).Value = dteSub
        cmdJzTruckInsert.Parameters.Add("@Initials", SqlDbType.NVarChar, 50).Value = strInitials
        Catch ex As Exception
        End Try
        Me.lblTruckSubmitted.Visible = True
    End Sub
End Class

Open in new window

Question by:bhorlings
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 33

Expert Comment

ID: 21875610
It would really help to mention what problem you are having / error message you are receiving!

Author Comment

ID: 21876244
My apologies. When I click submit everything looks like the query is executing and performing the insert command but it does not.
LVL 33

Accepted Solution

raterus earned 750 total points
ID: 21876382
You have an empty Catch statement, which is the quickest way to "ignore" errors and never know there is a problem!

rewrite this

        Catch ex As Exception
        End Try

to this, and you should see the problem

        End Try

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question