Browser Dialog error with DateTime fields range


Author
Message
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi,

I have a Browser Dialog in which I need to search on a DateTime field (using the date portion only) using a range condition >= and <=.  I added the same field CallDateTime twice with the >= and <= condition (see attached image), and when doing the search I got the following error:

ArgumentException
  An item with the same key has already been added.

Source     : mscorlib

Stack Trace:
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogSearchingEventArgs..ctor(BrowseDialog Browse, WhereStatementCollection WhereStatements)
   at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogwindow.ExecuteSearch()
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
   at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

As I understand, this error may be generated by adding the field twice in the browser dialog, so if this is the case, how can I handle a search on the CallDateTime field using a range date for the same field?

Edhy Rijo

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Well, you should be able to use the same field twice.  Could you post the stack trace for the error that you're receiving (maybe from the red exception dialog that you get).  Sounds like it's a Dictionary<TKey,TItem> issue, but I'm not sure where it might be coming from.
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Ben Chase (10/16/2007)
Could you post the stack trace for the error that you're receiving (maybe from the red exception dialog that you get).

Hi Ben,

I posted the stack trace in the original message from the red exception dialog Hehe

Do you need something else?

Edhy Rijo

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Hehe, nope, I just looked right past it... sorry.
StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Looks like when we added the functionality for the Searching event, we didn't take into consideration the fact that more than one of each field might make it into the list.  Here are the DLLs for the fix.
Attachments
StrataFrame.zip (87 views, 1.00 MB)
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Ben,

Thanks for the zip file, the new dlls fixed the exception problem, but I still have some issues with the datetime range feature.

Notice in the 1st picture that I did a Search without selecting the CallDateTime fields and returned 3 records, one with today's date.

Now noticed in the 2nd picture that when I select the CallDateTime fields, I don't get any record, even thought there is a record with today's date.

Edhy Rijo

Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Edhy Rijo (10/16/2007)
Hi Ben,

Thanks for the zip file, the new dlls fixed the exception problem, but I still have some issues with the datetime range feature.

Notice in the 1st picture that I did a Search without selecting the CallDateTime fields and returned 3 records, one with today's date.

Now noticed in the 2nd picture that when I select the CallDateTime fields, I don't get any record, even thought there is a record with today's date.

Hi Ben, Trent,

Could you please check this problem above.

Thanks!

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Edhy,

I think I know what is going on here.  If you change the ending time to the 17th, do any records show up?  I think that this has to do with the time.  By default, a DateTime has both parts, a date value and a time value and I do not think that the time is being ignore.  I think by default the time is cleared out so it would be midnight.  So in your example, the query is actually trying to search by this:

WHERE callDate >= '10/16/2007 12:00:00 AM' AND callDate <= '10/16/2007 12:00:00 AM'

So as you could see, unless there was an actual call placed at exactly midnight on the 16th, a record will no appear.  There probably needs to be an enhancement that allows the time to be specified along with the date versus always clearing to midnight.  For example, you would either choose clear to midnight or set to the end of the day (11:59:59 PM).  This way you would not have this particular issue.

Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Trent L. Taylor (10/19/2007)
There probably needs to be an enhancement that allows the time to be specified along with the date versus always clearing to midnight.  For example, you would either choose clear to midnight or set to the end of the day (11:59:59 PM).  This way you would not have this particular issue.

Hi Trent,

You are right on the spot, the datetime data stored in the database is 10/16/2007 10:30:00pm, by changing the ending time to 17th I was able to get the correct record in the browser dialog.  The situation is that we don't have any way change the value of the controls in the BD other than the InitialValue, guess we need more hooks to handle this kind of situation.

About the enhancement, I would prefer to deal only with the date part instead of date and time, so you can maybe add a new option in the Search Field Criteria form to handle Date Ranges and internally modify the time from 12:00:00 AM to 11:59:59 PM of the user's selected date ranges.

Please let me know your plans on this, since I do really need to provide the end use with a way to search on records for specific date in this form.

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
About the enhancement, I would prefer to deal only with the date part instead of date and time,

Well, this really isn't an option since the field in the table is a DateTime.  You can use some functions in SQL Server to ignore the time, but this slows the query, and is not the same for all databases.  This is on our "to-look-at" list.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search