By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 2,212 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

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

P: n/a
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!
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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!
Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.