Hi.
I'm trying to make a criteria string to use in Select() method of a datatable, searching for a date, but it is apparently not working!
In one of my tests, I have a datatable with 1 row and a field containing the following value (extracted from Immediate Window):
?dtbSample.Rows(0).Item("COM_STARTDATE")
#5/8/2006 9:00:00 AM# {Date}
Date: #5/8/2006 9:00:00 AM#
(for better understand, consider this date as '2006/05/08')
Then, I test a criterium to DON'T show that row, using this:
arrRows = dtbSample.Select("COM_STARTDATE >= '2006/05/09'")
Now, look the results in immediate window:
?arrRows.Length
1
!!!!!!
The Select() is returning a DataRow with a date less than the specified criterium, which is requiring a date higher than existing in the DataTable!!
In resume, '2006/05/08' is less than "COM_STARTDATE >= '2006/05/09'", but is returning like if '2006/05/08' is higher.
Someone already noticed that behaviour? There is a way to fix it?
Cesar
ps.:
For you know, I tryied to build criteria like below and still is returning row (not working):
("COM_STARTDATE >= #'2006/05/09#") 'yyyy/MM/dd and #
("COM_STARTDATE >= '05/09/2006'") 'MM/dd/yyyy
("COM_STARTDATE >= '" & TheDate.ToString & "'") 'a Date datatype
("COM_STARTDATE >= #05/09/2006#") 'MM/dd/yyyy and #
("COM_STARTDATE >= #May/09/2006#") 'MMM/dd/yyyy and #
I repeat, these don't works!! They are returning the row. :^P 6 4674
OUCH! Found it... the Select() method by default, searches only for commited data.... and my DataRow was not yet commited by the AcceptChanges() method.
Then, to fix it, i should use:
arrRows = dtbSample.Select("COM_STARTDATE >= #May/09/2006#", "", DataViewRowState.ModifiedCurrent)
The third parameter now makes the method works like I want.
[]s
Cesar
"ronchese" <info(a)carsoftnet.com.br> wrote in message news:eu*************@TK2MSFTNGP02.phx.gbl...
Hi.
I'm trying to make a criteria string to use in Select() method of a datatable, searching for a date, but it is apparently not working!
In one of my tests, I have a datatable with 1 row and a field containing the following value (extracted from Immediate Window):
?dtbSample.Rows(0).Item("COM_STARTDATE")
#5/8/2006 9:00:00 AM# {Date}
Date: #5/8/2006 9:00:00 AM#
(for better understand, consider this date as '2006/05/08')
Then, I test a criterium to DON'T show that row, using this:
arrRows = dtbSample.Select("COM_STARTDATE >= '2006/05/09'")
Now, look the results in immediate window:
?arrRows.Length
1
!!!!!!
The Select() is returning a DataRow with a date less than the specified criterium, which is requiring a date higher than existing in the DataTable!!
In resume, '2006/05/08' is less than "COM_STARTDATE >= '2006/05/09'", but is returning like if '2006/05/08' is higher.
Someone already noticed that behaviour? There is a way to fix it?
Cesar
ps.:
For you know, I tryied to build criteria like below and still is returning row (not working):
("COM_STARTDATE >= #'2006/05/09#") 'yyyy/MM/dd and #
("COM_STARTDATE >= '05/09/2006'") 'MM/dd/yyyy
("COM_STARTDATE >= '" & TheDate.ToString & "'") 'a Date datatype
("COM_STARTDATE >= #05/09/2006#") 'MM/dd/yyyy and #
("COM_STARTDATE >= #May/09/2006#") 'MMM/dd/yyyy and #
I repeat, these don't works!! They are returning the row. :^P
Cesar,
I suspect that '2006/05/09' is not being translated properly.
Try:
arrRows = dtbSample.Select("COM_STARTDATE >= #05/09/2006#")
As Date values in DataSet expressions need to be delimited by #. http://msdn.microsoft.com/library/de...ssiontopic.asp
I believe the date values are in m/d/y format.
Something like:
Dim table As New DataTable
table.Columns.Add("COM_STARTDATE", GetType(DateTime))
table.Rows.Add(#5/8/2006 9:00:00 AM#)
Dim rows() As DataRow = table.Select("COM_STARTDATE >=
#05/09/2006#")
--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"ronchese" <info(a)carsoftnet.com.br> wrote in message
news:eu*************@TK2MSFTNGP02.phx.gbl...
Hi.
I'm trying to make a criteria string to use in Select() method of a
datatable, searching for a date, but it is apparently not working!
In one of my tests, I have a datatable with 1 row and a field containing the
following value (extracted from Immediate Window):
?dtbSample.Rows(0).Item("COM_STARTDATE")
#5/8/2006 9:00:00 AM# {Date}
Date: #5/8/2006 9:00:00 AM#
(for better understand, consider this date as '2006/05/08')
Then, I test a criterium to DON'T show that row, using this:
arrRows = dtbSample.Select("COM_STARTDATE >= '2006/05/09'")
Now, look the results in immediate window:
?arrRows.Length
1
!!!!!!
The Select() is returning a DataRow with a date less than the specified
criterium, which is requiring a date higher than existing in the DataTable!!
In resume, '2006/05/08' is less than "COM_STARTDATE >= '2006/05/09'", but is
returning like if '2006/05/08' is higher.
Someone already noticed that behaviour? There is a way to fix it?
Cesar
ps.:
For you know, I tryied to build criteria like below and still is returning
row (not working):
("COM_STARTDATE >= #'2006/05/09#") 'yyyy/MM/dd and #
("COM_STARTDATE >= '05/09/2006'") 'MM/dd/yyyy
("COM_STARTDATE >= '" & TheDate.ToString & "'") 'a Date datatype
("COM_STARTDATE >= #05/09/2006#") 'MM/dd/yyyy and #
("COM_STARTDATE >= #May/09/2006#") 'MMM/dd/yyyy and #
I repeat, these don't works!! They are returning the row. :^P
I tryied # also, like showed in PS area, at end of e-mail :D ps.: For you know, I tryied to build criteria like below and still is returning row (not working): ("COM_STARTDATE >= #'2006/05/09#") 'yyyy/MM/dd and # ("COM_STARTDATE >= '05/09/2006'") 'MM/dd/yyyy ("COM_STARTDATE >= '" & TheDate.ToString & "'") 'a Date datatype ("COM_STARTDATE >= #05/09/2006#") 'MM/dd/yyyy and # ("COM_STARTDATE >= #May/09/2006#") 'MMM/dd/yyyy and #
But the problem was the rows not commited, and the Select() only searches in commited data.
I posted the solution in a other reply.
Thanks anyway, for response.
[]s
Cesar
"Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> wrote in message news:%2****************@TK2MSFTNGP05.phx.gbl... Cesar, I suspect that '2006/05/09' is not being translated properly. Try: arrRows = dtbSample.Select("COM_STARTDATE >= #05/09/2006#") As Date values in DataSet expressions need to be delimited by #. http://msdn.microsoft.com/library/de...ssiontopic.asp I believe the date values are in m/d/y format. Something like: Dim table As New DataTable table.Columns.Add("COM_STARTDATE", GetType(DateTime)) table.Rows.Add(#5/8/2006 9:00:00 AM#) Dim rows() As DataRow = table.Select("COM_STARTDATE >= #05/09/2006#") -- Hope this helps Jay B. Harlow [MVP - Outlook] .NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net "ronchese" <info(a)carsoftnet.com.br> wrote in message news:eu*************@TK2MSFTNGP02.phx.gbl... Hi. I'm trying to make a criteria string to use in Select() method of a datatable, searching for a date, but it is apparently not working! In one of my tests, I have a datatable with 1 row and a field containing the following value (extracted from Immediate Window): ?dtbSample.Rows(0).Item("COM_STARTDATE") #5/8/2006 9:00:00 AM# {Date} Date: #5/8/2006 9:00:00 AM# (for better understand, consider this date as '2006/05/08') Then, I test a criterium to DON'T show that row, using this: arrRows = dtbSample.Select("COM_STARTDATE >= '2006/05/09'") Now, look the results in immediate window: ?arrRows.Length 1 !!!!!! The Select() is returning a DataRow with a date less than the specified criterium, which is requiring a date higher than existing in the DataTable!! In resume, '2006/05/08' is less than "COM_STARTDATE >= '2006/05/09'", but is returning like if '2006/05/08' is higher. Someone already noticed that behaviour? There is a way to fix it? Cesar ps.: For you know, I tryied to build criteria like below and still is returning row (not working): ("COM_STARTDATE >= #'2006/05/09#") 'yyyy/MM/dd and # ("COM_STARTDATE >= '05/09/2006'") 'MM/dd/yyyy ("COM_STARTDATE >= '" & TheDate.ToString & "'") 'a Date datatype ("COM_STARTDATE >= #05/09/2006#") 'MM/dd/yyyy and # ("COM_STARTDATE >= #May/09/2006#") 'MMM/dd/yyyy and # I repeat, these don't works!! They are returning the row. :^P
Hmmm... After some testes, I noticed that the value DataViewRowState.CurrentRows works better than the previous I told.
Example:
arrRows = dtbSample.Select(strCrit, "", DataViewRowState.CurrentRows)
[]s
Cesar
"ronchese" <info(a)carsoftnet.com.br> wrote in message news:u9**************@TK2MSFTNGP04.phx.gbl...
OUCH! Found it... the Select() method by default, searches only for commited data.... and my DataRow was not yet commited by the AcceptChanges() method.
Then, to fix it, i should use:
arrRows = dtbSample.Select("COM_STARTDATE >= #May/09/2006#", "", DataViewRowState.ModifiedCurrent)
The third parameter now makes the method works like I want.
[]s
Cesar
"ronchese" <info(a)carsoftnet.com.br> wrote in message news:eu*************@TK2MSFTNGP02.phx.gbl...
Hi.
I'm trying to make a criteria string to use in Select() method of a datatable, searching for a date, but it is apparently not working!
In one of my tests, I have a datatable with 1 row and a field containing the following value (extracted from Immediate Window):
?dtbSample.Rows(0).Item("COM_STARTDATE")
#5/8/2006 9:00:00 AM# {Date}
Date: #5/8/2006 9:00:00 AM#
(for better understand, consider this date as '2006/05/08')
Then, I test a criterium to DON'T show that row, using this:
arrRows = dtbSample.Select("COM_STARTDATE >= '2006/05/09'")
Now, look the results in immediate window:
?arrRows.Length
1
!!!!!!
The Select() is returning a DataRow with a date less than the specified criterium, which is requiring a date higher than existing in the DataTable!!
In resume, '2006/05/08' is less than "COM_STARTDATE >= '2006/05/09'", but is returning like if '2006/05/08' is higher.
Someone already noticed that behaviour? There is a way to fix it?
Cesar
ps.:
For you know, I tryied to build criteria like below and still is returning row (not working):
("COM_STARTDATE >= #'2006/05/09#") 'yyyy/MM/dd and #
("COM_STARTDATE >= '05/09/2006'") 'MM/dd/yyyy
("COM_STARTDATE >= '" & TheDate.ToString & "'") 'a Date datatype
("COM_STARTDATE >= #05/09/2006#") 'MM/dd/yyyy and #
("COM_STARTDATE >= #May/09/2006#") 'MMM/dd/yyyy and #
I repeat, these don't works!! They are returning the row. :^P
Working more, I got another problems with some other uses for select()... After break the head a bit more, I found that DataBindings was the root for causing all the troubles. Then, after I set:
BindingContext(dtb).SuspendLayout()
... when the form closes, everything work like nothing was happened.
And then, I even dont needed that 3rd parameter in the Select() commands I used. Rewrote everything again. :D
[]s
Cesar
"ronchese" <info(a)carsoftnet.com.br> wrote in message news:Og**************@TK2MSFTNGP03.phx.gbl...
Hmmm... After some testes, I noticed that the value DataViewRowState.CurrentRows works better than the previous I told.
Example:
arrRows = dtbSample.Select(strCrit, "", DataViewRowState.CurrentRows)
[]s
Cesar
"ronchese" <info(a)carsoftnet.com.br> wrote in message news:u9**************@TK2MSFTNGP04.phx.gbl...
OUCH! Found it... the Select() method by default, searches only for commited data.... and my DataRow was not yet commited by the AcceptChanges() method.
Then, to fix it, i should use:
arrRows = dtbSample.Select("COM_STARTDATE >= #May/09/2006#", "", DataViewRowState.ModifiedCurrent)
The third parameter now makes the method works like I want.
[]s
Cesar
"ronchese" <info(a)carsoftnet.com.br> wrote in message news:eu*************@TK2MSFTNGP02.phx.gbl...
Hi.
I'm trying to make a criteria string to use in Select() method of a datatable, searching for a date, but it is apparently not working!
In one of my tests, I have a datatable with 1 row and a field containing the following value (extracted from Immediate Window):
?dtbSample.Rows(0).Item("COM_STARTDATE")
#5/8/2006 9:00:00 AM# {Date}
Date: #5/8/2006 9:00:00 AM#
(for better understand, consider this date as '2006/05/08')
Then, I test a criterium to DON'T show that row, using this:
arrRows = dtbSample.Select("COM_STARTDATE >= '2006/05/09'")
Now, look the results in immediate window:
?arrRows.Length
1
!!!!!!
The Select() is returning a DataRow with a date less than the specified criterium, which is requiring a date higher than existing in the DataTable!!
In resume, '2006/05/08' is less than "COM_STARTDATE >= '2006/05/09'", but is returning like if '2006/05/08' is higher.
Someone already noticed that behaviour? There is a way to fix it?
Cesar
ps.:
For you know, I tryied to build criteria like below and still is returning row (not working):
("COM_STARTDATE >= #'2006/05/09#") 'yyyy/MM/dd and #
("COM_STARTDATE >= '05/09/2006'") 'MM/dd/yyyy
("COM_STARTDATE >= '" & TheDate.ToString & "'") 'a Date datatype
("COM_STARTDATE >= #05/09/2006#") 'MM/dd/yyyy and #
("COM_STARTDATE >= #May/09/2006#") 'MMM/dd/yyyy and #
I repeat, these don't works!! They are returning the row. :^P
Ronchese,
That the Select is buggy is in my idea not even testable because the lack of documentation around the Expression.
However, AFAIK has a date in the select in VB to be the USA date literal as you have used in your example. The Expression is AFAIK totaly based on USA behaviour.
I hope this helps a little bit.
Cor
"ronchese" <info(a)carsoftnet.com.br> schreef in bericht news:eu*************@TK2MSFTNGP02.phx.gbl...
Hi.
I'm trying to make a criteria string to use in Select() method of a datatable, searching for a date, but it is apparently not working!
In one of my tests, I have a datatable with 1 row and a field containing the following value (extracted from Immediate Window):
?dtbSample.Rows(0).Item("COM_STARTDATE")
#5/8/2006 9:00:00 AM# {Date}
Date: #5/8/2006 9:00:00 AM#
(for better understand, consider this date as '2006/05/08')
Then, I test a criterium to DON'T show that row, using this:
arrRows = dtbSample.Select("COM_STARTDATE >= '2006/05/09'")
Now, look the results in immediate window:
?arrRows.Length
1
!!!!!!
The Select() is returning a DataRow with a date less than the specified criterium, which is requiring a date higher than existing in the DataTable!!
In resume, '2006/05/08' is less than "COM_STARTDATE >= '2006/05/09'", but is returning like if '2006/05/08' is higher.
Someone already noticed that behaviour? There is a way to fix it?
Cesar
ps.:
For you know, I tryied to build criteria like below and still is returning row (not working):
("COM_STARTDATE >= #'2006/05/09#") 'yyyy/MM/dd and #
("COM_STARTDATE >= '05/09/2006'") 'MM/dd/yyyy
("COM_STARTDATE >= '" & TheDate.ToString & "'") 'a Date datatype
("COM_STARTDATE >= #05/09/2006#") 'MM/dd/yyyy and #
("COM_STARTDATE >= #May/09/2006#") 'MMM/dd/yyyy and #
I repeat, these don't works!! They are returning the row. :^P This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Luc |
last post by:
I am using Visual Studio 2003 and am getting lousy performance after using
a datatable select and then trying to assign a value to a column of the row
that was found:
DataTable dt = new...
|
by: Kris Rudin |
last post by:
I am displaying a table of information on a web page, using an asp:table
that I populate dynamically. On this page I give the user the options to
group the rows by certain fields, and/or filter the...
|
by: Marcel Hug |
last post by:
Hi NG!
With a Inner-Join SQL I get my datas in a DataSet.
In the table are the column Entry and Version.
Like this:
Entry Version
1 1
1 2
1 ...
|
by: wk6pack |
last post by:
Hi,
How do I check datatable.select(filter) in the following:
for each dtrow in datatable.select(filter)
....
next
I've also tried:
|
by: Aryan |
last post by:
Hi,
I am having problem with DataTable.Select() method. I am using
ASP.NET 2.0.
I have DataSet which reads data from XML file using DataSet.ReadXML().
Now this
dataset has various datatable,...
| |
by: Maxwell2006 |
last post by:
Hi,
I am working with strongly typed datatables.
What is the most efficient way to build a new DataTAble based on the result
of DataTable.Select?
At this point I use a foreach loop to do the...
|
by: Manikandan |
last post by:
Hi,
I have a datatable with rows.
When I used datatable.select with values it is working properly,
But when I use the select with variables it is not working.
I tried with putting '(single...
|
by: Massimo |
last post by:
Hi to All,
i'm using C# in .NET 2.0 and i have a DataTable A with a column of
type TimeSpan used to store HOUR info.
I'm trying to filter my DataTable A selecting only rows that have the
column...
|
by: Jeff |
last post by:
hey
..NET 2.0
I have a datatable which consist of 3 columns (int, date, value). This
DataTable have 3 rows, the values of the "date" ("date" column is of
datetime datatype) column is:...
|
by: Nuno Magalhaes |
last post by:
Hello,
I have a DataTable in which the items are of type MyClass.
How can I use Select to compare a MyClass instance with the DataTable?
Is there any overriden method (like the ToString()) to...
|
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...
| |
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
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 ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |