Date entered from textbox becomes null (1/1/1900) when entered into SQL table.

Discussion in 'ASP .Net' started by TN Bella, Jul 1, 2004.

  1. TN Bella

    TN Bella Guest

    Hello,

    I was looking through the older posts for a solution to this problem,
    but I am still confused on how to fix my problem. There are two dates on
    my form, one (txtInvDate) is entered by the user and has a validator
    (reDate) attached for specific dates that can be entered. The second
    date (txtRptDate) is another textbox that is filled with current date,
    that can not be changed by the user. The date (txtRptDate) that cannot
    be changed by the user inputs fine into my SQL table, however the other
    date (txtInvDate) does not, instead I get a null value 1/1/1900. How can
    I fix the txtInvDate to work like the other inserted date?

    This is something that I have tried:

    Dim MySQL as string = "Insert into a_p.dbo.tbl_ap_web_ce_inv_terms
    (splr_cd, rpt_date, inv_numb, inv_dat) Values ('" & txtSupCD.text &
    "','" & txtRptDate.text & "','" & txtInvNum.text & "'," &
    CType(txtInvDate.text,Date).ToShortDateString & ")"

    Both dates are set for datetime 8 in the SQL table, inv_dat (txtInvDate)
    is one of the three primary keys (I took the primary key off of inv_dat
    and it still didn't work correctly) .

    and my first attempt:
    & txtInvDate.text & ")"

    'reDate is the validator for txtInvDate
    'Validation for Invoice Date, dates < 3 years OR > 30 days are
    not accepted
    reDate.MinimumValue =
    CDate(DateTime.Now.AddYears(-3).ToShortDateString)
    reDate.MaximumValue =
    CDate(DateTime.Now.AddDays(30).ToShortDateString)

    'Current date input for Receipt Date textbox, it can't not be
    changed by user.
    txtRptDate.Text = DateTime.Now.ToShortDateString()

    'Here are my textboxes:
    <asp:textbox id="txtInvDate" runat="server"
    Width="97px"></asp:textbox>
    <asp:RangeValidator id="reDate"
    runat="server" ErrorMessage="Invoice Date"
    ControlToValidate="txtInvDate" EnableClientScript="true"
    type="Date">Please make sure the date is not older than 3 years or
    greater than 30 days.</asp:RangeValidator>

    <asp:TextBox id="txtRptDate" runat="server"
    Width="96px" Enabled="False"></asp:TextBox>

    Thanks in advance for any assistance to this problem, it has been
    driving me nuts!! Thank you!
    Oh, one more thing..>I am using Web Matrix 1.0 net framework in VB and
    not C#.

    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
    TN Bella, Jul 1, 2004
    #1
    1. Advertising

  2. TN Bella

    TN Bella Guest

    Thanks for looking at my problem but it is now fixed.

    ...I was missing the single quotes in my insert sql statement:

    "','" & CType(txtInvDate.text,Date).ToShortDateString & "')"

    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
    TN Bella, Jul 1, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    9
    Views:
    970
    Juha Nieminen
    Aug 22, 2007
  2. Stef Mientki

    and becomes or and or becomes and

    Stef Mientki, May 22, 2011, in forum: Python
    Replies:
    9
    Views:
    312
    Chris Angelico
    May 28, 2011
  3. Renie83
    Replies:
    1
    Views:
    311
    Ray at
    Jul 9, 2003
  4. Aaron [SQL Server MVP]

    Date in SQL: 1/1/1900

    Aaron [SQL Server MVP], Jun 9, 2004, in forum: ASP General
    Replies:
    5
    Views:
    142
    Ice Man
    Jun 11, 2004
  5. Replies:
    1
    Views:
    205
    Jano Svitok
    Jul 17, 2007
Loading...

Share This Page