|
if that is the way dates are kept all the time (I do find that hard to believe), then they are bound
to have a way to do date comparisons and date range checks based on that format too...
I am afraid I can't help you any further, I am no database expert, and never addressed an AS400.
|
|
|
|
|
Luc, that's the way they do it in mainframe server. But the thing is that I'm looking for something which could actually help me in doing the date range comparison at the code level. Normally we do it at the database level but since my database doesn't have a date field, I've to do it at the code level. I'm saying so, coz my code concatenates the 4 different fields into one field and display it as date field on crystal report. So if there are chances of any comparison for date range then it has to be done at code level only coz that's the place where its actually shown up as date field.
Did i confused you...........????
To be more clear, I want the date range comparison to be done exactly after the code where its concatenating the fields.............and the code for the same is as given below:
for(Int32 i = 0; i < newPDS.Tables[0].Rows.Count; i++)
{
DataRow row = newPDS.Tables[0].Rows[i];
row["ADM_DATE"] = row["CADMMM"].ToString() + "/" + row["CADMDD"].ToString() + "/" + row["CADMHH"].ToString() + row["CADMYY"].ToString();
}
|
|
|
|
|
Hi,
if you have numeric values for year, month and day, you can create a new DateTime() instance
with the corresponding value DateTime dt=new DateTime(year, month, day);
[ADDED] If all you have is a datelike string, then you can try and extract a DateTime from it
using DateTime.Parse(), DateTime.ParseExact() or DateTime.TryParse().[/ADDED]
And when you have two DateTime instances you can compare them with the comparison operators
such as < and == and >
modified on Monday, July 28, 2008 2:21 PM
|
|
|
|
|
I wouldn't fetch all records and do it on client side, because it would unnecessarily create high load on the database server and fetch more records than actually needed. Can't you do something like this on server side?
SELECT ...
FROM table
WHERE YY >= startyear
AND MM >= startmonth
AND DD >= startday
AND YY <= endyear
AND MM <= endmonth
AND DD <= endday
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
The principle is OK, but the implementation is wrong.
There is a huge difference between date1<date2
and
year1<year2 AND month1<month2 AND day1<day2
The correct way would be something like this:
year1<year2 OR (year1==year2 AND (month1<month2 OR (..etc..))
|
|
|
|
|
I totally agree with what you guys are saying, but please let me know whether I can use the SELECT statement on DataSet the same way as we use on Database tables coz I don't have the datefield in database table, its only the newly created DataSet which is holding the DateField.
Let's say, the code goes like this :
DataColumn dCol = new DataColumn(newPDS.Tables[0].Columns.Add("ADM_DATE", typeof(String)).ToString());
for(Int32 i = 0; i < newPDS.Tables[0].Rows.Count; i++)
{
DataRow row = newPDS.Tables[0].Rows[i];
row["ADM_DATE"] = row["CADMMM"].ToString() + "/" + row["CADMDD"].ToString() + "/" + row["CADMHH"].ToString() + row["CADMYY"].ToString();
}
Now its the newPDS DataSet, which is having the DateField. So, now please tell me a way to apply the date range thing within this piece of code. (Date range from Form is entered in 2 Textboxes as START_DATE and END_DATE in the format of DD/MM/YYYY.
THANKS
|
|
|
|
|
I have a simple class that inherits from TextBox and has a member variable
ErrorProvider m_ErrorProvider
ErrorProvider has a dispose method so I've implemented IDisposable and my Dispose method is simply
void IDisposable.Dispose()
{
m_ErrorProvider.Dispose();
base.Dispose();
}
Is this sufficient?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
No.
You should override the bases Dispose(bool disposing) method.
Follow the dispose pattern[^] for a derived class.
Simon
|
|
|
|
|
I had just been on that page but missed the derived class bit!
Thanks.
So this should be OK?
void IDisposable.Dispose()
{
Dispose(true);
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
m_ErrorProvider.Dispose();
}
base.Dispose(disposing);
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
DaveyM69 wrote: I had just been on that page but missed the derived class bit!
Considering that the dispose pattern is one of the most used in .net, that page is really rather poorly laid out. It's pretty easy to miss.
DaveyM69 wrote: So this should be OK?
You don't need the unparamaterised dispose method. That is naturally inherited from the base.
void IDisposable.Dispose()
{
Dispose(true);
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
m_ErrorProvider.Dispose();
}
base.Dispose(disposing);
}
Simon
|
|
|
|
|
Cheers Simon
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Pleasure.
Simon
|
|
|
|
|
DaveyM69 wrote: Is this sufficient?
I believe so. Correct me if I'm wrong, but don't the destructors automatically call base.Dispose ?
----modified
Saw Simon's reply. Learned something new this morning.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hey everybody
I wondered if there is a way to connect to word application without the running object table.
Meaning, instead of getting the COM object from the ROT, ask from running instance of word (queryInterface or something like that...).
Thanks a lot!
|
|
|
|
|
what I found out until now:
Using the following code we're creating in C# a word application.
This application creates a new process of "winword.exe" because we're not checking the ROT for already running instances of word.
Type T = Type.GetTypeFromCLSID(new Guid("{000209FF-0000-0000-C000-000000000046}"));
Word.Application app = (Word.Application)Activator.CreateInstance(T);
app.visible = true;
What I still couldn't find is a way to connect to the running word (without ROT).
all I have is the Process ID.
I want to connect Word without waiting until it registers the ROT (in word's focus out event).
Thanks again!
|
|
|
|
|
Hello all,
I am having a bit o problem and i need a simple, elegant fix.
The problem: I am uploading a file to a ftp using FtpWebResponse and the Write method from a ftpRequest. I need this file locked for reading until all content has been uploaded to the Ftp and the write method has stopped.
Another app. (actually the same, but on a different machine) will download this file, and i need to read it only when the write method has stopped.
So far, my solutions do not work fully or are very very ... ugly
Thx
|
|
|
|
|
Hi,
If you're using Open-method on File class use FileShare.None for share parameter. This should prevent opening the file elsewhere.
Mika
|
|
|
|
|
How does the consumer process know there is a file to process?
And does the consumer use FTP to download the file, or is it on the machine your producer is
uploading to?
|
|
|
|
|
The consumer searches the ftp for a list of files with a given extension. (but it can also grab all the files from ftp, regardless of the extension. This part is configurable)
|
|
|
|
|
Here are some ways to consider:
1. have the consumer wait for a signal, and once it receives the signal make a list of available files,
then signal back to the producer; in between the consumer should not start creating new files.
2. have the producer use a fake extension, and once the file is uploaded, have it rename the extension;
3. have the producer a file, and once the file is uploaded, have it signal the consumer while
mentioning the file name.
As for signal, you could use anything available, including the creation and deletion of a file
that simply contains a filename.
My favorite would be 3, i.e. producer creates a file say file1.ext1, then it creates file
"currenttime.signal" containing the text "file1.ext1"; consumer would find all signal files,
read them, delete them, and process the file mentioned in them.
And I would use yyyyMMdd_HHmmss format for currenttime, so the signal files have identical alphabetical
and chronological order.
PS: if you are afraid two files need could be generated in the same second, just add a 2-second
delay in the producer code!
|
|
|
|
|
Thanks Luc.
The signal idea has crossed my mind, but not in such a superb manner .
I was afraid i would have to modify quite a lot, and that is not far from truth.
I retrospective, the whole architecture of the program should be reconsidered . Hopefully i'll have the time to do just that, and then i will implement your solution.
Thx all.
|
|
|
|
|
You're welcome.
|
|
|
|
|
I am making a simple chess game in my spare time. I have been thinking of the best way to check whether or not a move is valid for a certain piece.
Each "board square" has an index: 0 to 64. I have decided that when the player wants to make a move, I'll build a list of indexes that that piece can move to, and check whether or not the new position is in that list.
So, does anyone know of a better/easier way of checking the above?, i thought I'd post here before i crack on and see if anyone had any other ideas than me - thinking out of the box and all that. Cheers.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
|
enginço,
I don't want a complete game, as i want to learn, not copy. Also, the code looks horrible to say the least...
Regards,
Gareth.
(FKA gareth111)
|
|
|
|