473,394 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

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
1 2809
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: MrDom | last post by:
I am wondering if someone can help solve this question I have a table in sql server 2000, I setup it using Enterprise manager. When I generate an SQL Script for this table it scripts as: ...
10
by: sandraz444 | last post by:
I have an expression in the query under my form to autofill the date under a certain condition but it wont write to the underlying table?? The date shows in the form but not the table. Does anyone...
10
by: molen malat | last post by:
i have a query with 4 fields, and a form based on it. i put another 4 textbox to get criteria to filter the query. the query runs normally when all the textbox have a value (not null) but when one or...
2
by: Claes Wedin | last post by:
My customer needs a DateTimePicker in VS2005 C# that can show emty date values (blank/space/null). I need a control that: 1. Can show a blank value 2. Detete a date when hitting the delete...
5
by: Gohalien | last post by:
I am writing some code, and I wanna "ask" if an object name is not null (aka, the object exist) then do some work, else, do other work... Of course, by doing "If (textbox.name == null)" I get the...
3
by: janetopps | last post by:
I have a news website, with asp pages, which was on Access, and i upgraded to MySQL, i used Bullzip to transfer the data. It had about 1000 pages, which im now able to pull up on the public side. Im...
2
by: slao | last post by:
I am unable to get the updated value of textbox within a listview when "Update" link button is clicked which calls a function. <asp:ListView ID="_lvCartItems"...
3
by: hehe panda | last post by:
I have Access as FrontEnd and SQL server as Backend. After I call a stored procedure on the SQL server, I try to read the fields in the recordset. However, one of the column can only be used once....
10
by: hehe panda | last post by:
I have Access as FrontEnd and SQL server as Backend. After I call a stored procedure on the SQL server, I try to read the fields in the recordset. However, one of the column can only be used once....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.