473,785 Members | 2,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date Problem

Dear All,

I have a field in the datebase called ReacheIELTSDate with a DataType
"datetime"
with a length 8. I have a ASPX Web Form with several TEXTBOXES to insert
values into the database table. One of the textbox is attached to this date
field . I have a save button which saves the values in the datebase when the
user enters something in the txtdate text box. Thats fine I have no problem
with that. But when the txtdate box is left empty and I press a save button.
It inserts 01/01/1900 in the database table. which I dont want. All i want is
that when the text box is left empty and if i press a save button it should
insert empty value into the database field.

Below is the stored procedure I am using for updating the table
CREATE PROCEDURE UpdateProfessio nalExams

@reacheIeltsDat e datetime

Update HCP_Personal_De tails Set ReacheIELTSDate =@reacheIeltsDa te where
Hcp_Id=@hcpid

Below is the code behind the save button:

Dim conProfessional Exams As SqlConnection
Dim cmdUpdateProfes sion As SqlCommand

conProfessional Exams = New SqlConnection(A pplication("str Connection"))
conProfessional Exams.Open()
cmdUpdateProfes sion = New SqlCommand("Upd ateProfessional Exams",
conProfessional Exams)
cmdUpdateProfes sion .CommandType = CommandType.Sto redProcedure
cmdUpdateProfes sion .Parameters.Add ("@reacheIeltsD ate", txtIELTSDate.Te xt)
cmdUpdateProfes sion .Parameters.Add ("@hcpid", Session("Curren tHcpId"))
cmdUpdateProfes sion .ExecuteNonQuer y()
Nov 19 '05 #1
1 1116
you cannot store a blank in a datetime. you could store a null though.
change your code to test for blank, and if so set the parameter to dbnull,.
on retrieval, if null, set field to blank. you will have to check that the
proc and table support null in the column.

-- bruce (sqlwork.com)
"Sunil Sabir" <Su********@dis cussions.micros oft.com> wrote in message
news:30******** *************** ***********@mic rosoft.com...
| Dear All,
|
| I have a field in the datebase called ReacheIELTSDate with a DataType
| "datetime"
| with a length 8. I have a ASPX Web Form with several TEXTBOXES to insert
| values into the database table. One of the textbox is attached to this
date
| field . I have a save button which saves the values in the datebase when
the
| user enters something in the txtdate text box. Thats fine I have no
problem
| with that. But when the txtdate box is left empty and I press a save
button.
| It inserts 01/01/1900 in the database table. which I dont want. All i want
is
| that when the text box is left empty and if i press a save button it
should
| insert empty value into the database field.
|
| Below is the stored procedure I am using for updating the table
| CREATE PROCEDURE UpdateProfessio nalExams
|
| @reacheIeltsDat e datetime
|
| Update HCP_Personal_De tails Set ReacheIELTSDate =@reacheIeltsDa te where
| Hcp_Id=@hcpid
|
| Below is the code behind the save button:
|
| Dim conProfessional Exams As SqlConnection
| Dim cmdUpdateProfes sion As SqlCommand
|
| conProfessional Exams = New SqlConnection(A pplication("str Connection"))
| conProfessional Exams.Open()
| cmdUpdateProfes sion = New SqlCommand("Upd ateProfessional Exams",
| conProfessional Exams)
| cmdUpdateProfes sion .CommandType = CommandType.Sto redProcedure
| cmdUpdateProfes sion .Parameters.Add ("@reacheIeltsD ate",
txtIELTSDate.Te xt)
| cmdUpdateProfes sion .Parameters.Add ("@hcpid", Session("Curren tHcpId"))
| cmdUpdateProfes sion .ExecuteNonQuer y()
|
|
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4845
by: Laurence Neville | last post by:
This is regarding a change in the Short Date format under Hebrew Regional Settings, that has caused huge problems in our ASP web application. The change appears to have been introduced sometime before Windows 2000 Service Pack 4 and has remained through to Windows XP. I am looking for a solution that doesn't involve rewriting our application (much) and that allows all our users to keep using Hebrew Regional Settings. To summarize our...
7
8868
by: martini | last post by:
Need help: I am trying to call a DB2 stored procedure that requires parameters: 4x int, date, varchar, int. I use VB6 & oledb. I'm using statements: cmd.CommandText = "{call db2admin.proc(1, 0, 3, 3, '2002-04-22', '0000000', 351)}" and cmd.CommandText = "{call db2admin.proc(1, 0, 3, 3, {d '2002-04-22'}, '0000000', 351)}" and I get following error:
11
4226
by: David B | last post by:
I have 2 querys with the following in the date criteria Between DateAdd("m",-6,(!!)) And (!!) Between DateAdd("m",-24,(!!)) And DateAdd("m",-6,(!!)) Problem is they both look at the same day 6 months before the date entered. eg date entered = 28/02/2004 then both querys pick up data from 28/08/2003
3
3619
by: Dustin Wilson | last post by:
I have a problem with the following line of code. rstOutput! = FormatDateTime("January 1, 2004", vbLongDate) When I run this on my computer at home it runs without problem but when I run it at work I get a Run-time error '3421' Data type conversion error. I'm really stumped as to why this is. Both computers are Windows 2000 SP4 with Access 2000. The field is a Date/Time field with a format of Long Date set. Does anyone have an idea...
3
11583
by: Lyn | last post by:
Hi, I am developing a project in which I am checking for records with overlapping start/end dates. Record dates must not overlap date of birth, date of death, be in the future, and must not overlap existing records from the same table. I had this all working some time ago, but recently when I have gone back to do more testing, part of these validations no longer work. While there have been changes to the code in the meantime, I cannot...
2
6517
by: Julie Wardlow | last post by:
Help! I am calculating a future date using the DateAdd function in a query (the calculation also involves an IIf statement), and have managed to get this formula to produce the required result. I then want to search through the records and select those with dates (as caluclated above) within a user defined range, and so I am using a parameter query. However, this query returns dates outside of the range and appears to have particular...
1
2850
by: TN Bella | last post by:
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...
7
31843
by: James P. | last post by:
Hello there, In my asp.net page using VB, I have a date text field in mm/dd/yyyy format. When a date is entered, I'd like to validate it to make sure the date is greater than or equal to the current date. If not, I'd like to display the error message to ValidationSummary. It seems to make sense to me to use CompareValidator but the problem is put the current date into CompareValidator. So, I created a hidden text field in my aspx. ...
13
10707
by: Jim Armstrong | last post by:
Hi all - This problem has been driving me crazy, and I'm hoping the answer is something stupid I am neglecting to see.... The procedure posted below is part of an Access/SQL database I have developed. Basically, the user would input a beginning and ending date, and the query goes and pulls records that meet the following criteria: 1. TradeDate is between beginning date and ending date
7
2105
by: creative1 | last post by:
Hello everyone. I am experiencing a strange problem that I can't fix on my own. I think I need expert's suggestions for this. The problem is: I want to print account statement (or any other report) from VB form based on an entered date in the masked fields (dd/mm/yy). I am using one form to display five reports. I send date to display report after formatting it (m/dd/yy). When I enter date range like this in masked textbox (DD/MM/YY) ...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10330
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9952
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8976
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.