473,385 Members | 1,375 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,385 software developers and data experts.

Simple Date Question

Yog
I am trying to update a date column in dataset from a textbox.

When a date is changed in textbox, the dataset should reflect this,
similarly when the textbox is cleared to null the dataset should reflect
this. This is since i use the "DataViewRowState.ModifiedCurrent" later to
detect the changes for update.

How do we acheive this?.

Currently since i am ignoring nulls, i miss the null condition.
if (this.HIRE_DT.Text.ToString().Trim() != ""){

oRow["HIRE_DT"] =
Convert.ToDateTime(this.HIRE_DT.Text.ToString().Tr im());

}

Thank you,

Yog
Jul 21 '05 #1
3 1219
What are you asking exactly? Howe to set a date field in a dataset to null?

oRow["HIRE_DT"] = DBNull.Value;

"Yog" <sh******@hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
I am trying to update a date column in dataset from a textbox.

When a date is changed in textbox, the dataset should reflect this,
similarly when the textbox is cleared to null the dataset should reflect
this. This is since i use the "DataViewRowState.ModifiedCurrent" later to
detect the changes for update.

How do we acheive this?.

Currently since i am ignoring nulls, i miss the null condition.
if (this.HIRE_DT.Text.ToString().Trim() != ""){

oRow["HIRE_DT"] =
Convert.ToDateTime(this.HIRE_DT.Text.ToString().Tr im());

}

Thank you,

Yog

Jul 21 '05 #2
Yog
Thanks Marina, partly yes.

But my aim is to reduce the number of DB calls, and do an update only when a
change is detected.

If I have the code the following way,

if (this.HIRE_DT.Text.ToString().Trim() != ""){
oRow["HIRE_DT"] = Convert.ToDatei
Time(this.HIRE_DT.Text.ToString().Trim());
}else{
oRow["HIRE_DT"] = DBNull.Value;
}

Assuming the date in the HIRE_DT textbox was null initially, since i am
setting an explicit DBNull.Value here again, even though the user doesn't do
anything in the UI, the program will set a DBNull.Value and the dataset
detects a change

ie.
ds.HasChanges() will detect a change, and DataViewRowState.ModifiedCurrent
will do an extra DB call.

Thank you,
Yog

"Marina" <so*****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
What are you asking exactly? Howe to set a date field in a dataset to null?
oRow["HIRE_DT"] = DBNull.Value;

"Yog" <sh******@hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
I am trying to update a date column in dataset from a textbox.

When a date is changed in textbox, the dataset should reflect this,
similarly when the textbox is cleared to null the dataset should reflect
this. This is since i use the "DataViewRowState.ModifiedCurrent" later to detect the changes for update.

How do we acheive this?.

Currently since i am ignoring nulls, i miss the null condition.
if (this.HIRE_DT.Text.ToString().Trim() != ""){

oRow["HIRE_DT"] =
Convert.ToDateTime(this.HIRE_DT.Text.ToString().Tr im());

}

Thank you,

Yog


Jul 21 '05 #3
In this case, check if the value in the dataset is already the same as what
you want to set it too. If it is, don't do anything. Otherwise do the set.

"Yog" <sh******@hotmail.com> wrote in message
news:uw**************@tk2msftngp13.phx.gbl...
Thanks Marina, partly yes.

But my aim is to reduce the number of DB calls, and do an update only when a change is detected.

If I have the code the following way,

if (this.HIRE_DT.Text.ToString().Trim() != ""){
oRow["HIRE_DT"] = Convert.ToDatei
Time(this.HIRE_DT.Text.ToString().Trim());
}else{
oRow["HIRE_DT"] = DBNull.Value;
}

Assuming the date in the HIRE_DT textbox was null initially, since i am
setting an explicit DBNull.Value here again, even though the user doesn't do anything in the UI, the program will set a DBNull.Value and the dataset
detects a change

ie.
ds.HasChanges() will detect a change, and DataViewRowState.ModifiedCurrent
will do an extra DB call.

Thank you,
Yog

"Marina" <so*****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
What are you asking exactly? Howe to set a date field in a dataset to

null?

oRow["HIRE_DT"] = DBNull.Value;

"Yog" <sh******@hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
I am trying to update a date column in dataset from a textbox.

When a date is changed in textbox, the dataset should reflect this,
similarly when the textbox is cleared to null the dataset should reflect this. This is since i use the "DataViewRowState.ModifiedCurrent" later to detect the changes for update.

How do we acheive this?.

Currently since i am ignoring nulls, i miss the null condition.
if (this.HIRE_DT.Text.ToString().Trim() != ""){

oRow["HIRE_DT"] =
Convert.ToDateTime(this.HIRE_DT.Text.ToString().Tr im());

}

Thank you,

Yog



Jul 21 '05 #4

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

Similar topics

5
by: gsv2com | last post by:
Maybe I'm tired, but I'm having a small problem with a date function I'm writing. Total noobish I know, but this is just going beyond me for some reason... What I want to happen is send a date...
5
by: gene.ellis | last post by:
Hello everyone, I am really having a lot of trouble understanding the DOM and I doing something quite basic. I need to the DOM (in PHP 5) to modify an XML file. For example the XML basically...
13
by: LRW | last post by:
Having a problem getting a onSubmit function to work, to where it popsup a confirmation depending on which radiobutton is selected. Here's what I have: function checkdel() { if...
3
by: trinity | last post by:
I have two columns: Plantdate Totalpower 9/26/02 6217 10/31/02 5187 11/28/02 4246 12/26/02 4132 1/23/03 4313 2/21/03 4416 3/21/03 4355
6
by: KevinD | last post by:
assumption: I am new to C and old to COBOL I have been reading a lot (self teaching) but something is not sinking in with respect to reading a simple file - one record at a time. Using C, I am...
2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
18
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How...
7
by: Scott Frankel | last post by:
Still too new to SQL to have run across this yet ... How does one return the latest row from a table, given multiple entries of varying data? i.e.: given a table that looks like this: color...
1
by: Phillip Vong | last post by:
I have a simple Formview and in the InsertMode I have a calendar and a textbox. All I want is for people to click on a date and the date is populated to the textbox. Here is my simple code and my...
1
by: cppaddict | last post by:
I have dates like "8/27" or "9/4", and I need to convert them to date objects. When choosing a year, we should go backwards until we find the first match. That is, if the script runs on Jan 1,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.