473,398 Members | 2,812 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,398 software developers and data experts.

Global Date Filter for DataAdapter?

I've a DataAdapter with:

SELECT ID, Employee, [Date], Period_End_Date, Job, Description, Exported,
Units, Cost_Code, Category, Class, Chargeout_Level, PayID, Rate
FROM tblTimeEntry
WHERE (Employee LIKE ?) AND (Period_End_Date = ?)
ORDER BY [Date]

I then get my Data by the following:

' Select Data Based upon Current Week Ending and Employee ID
daUserData.SelectCommand.Parameters.Add("@Employee ", OleDbType.Char.Char, 10)
daUserData.SelectCommand.Parameters.Add("@MyDateFi eld ", OleDbType.Date)
daUserData.SelectCommand.Parameters(0).Value = strUserID
daUserData.SelectCommand.Parameters(1).Value = WeekEndDate
daUserData.Fill(DsUserData.tblTimeEntry)

with the 'date' variable WeekEndDate I choose a 'specific' date.

What I'd like to know, is what do I use as a 'global' search for ALL dates
using the above?

"%" and "*" of course do not work as I have to search a 'DATE'.

Anyone know?

Thanks

Toby
Jul 21 '05 #1
14 1816
Hi Toby,

You cannot use any wildcards for the dates. What you could do here is to use
SQL statement without date condition or use doubled condition for the date
and pass range of the dates, which basically covers everything. Something
like

SELECT ID, Employee, [Date], Period_End_Date, Job, Description,
Exported,
Units, Cost_Code, Category, Class, Chargeout_Level, PayID, Rate
FROM tblTimeEntry
WHERE (Employee LIKE ?) AND Period_End_Date >= ? AND Period_End_Date <=
?
ORDER BY [Date]

daUserData.SelectCommand.Parameters.Add("@Employee ", OleDbType.Char.Char,
10)
daUserData.SelectCommand.Parameters.Add("@MyDateFi eld1", OleDbType.Date)
daUserData.SelectCommand.Parameters.Add("@MyDateFi eld2", OleDbType.Date)
daUserData.SelectCommand.Parameters(0).Value = strUserID
daUserData.SelectCommand.Parameters(1).Value = WeekStartDate
daUserData.SelectCommand.Parameters(2).Value = WeekEndDate
daUserData.Fill(DsUserData.tblTimeEntry)

In case wehn you need to check for one date, you could pass it as a value
for both parameters

--
Val Mazur
Microsoft MVP
Check Virus Alert, stay updated
http://www.microsoft.com/security/incident/blast.asp
"Toby" <pl****@PostTo.NGs> wrote in message
news:tr********************************@4ax.com...
I've a DataAdapter with:

SELECT ID, Employee, [Date], Period_End_Date, Job, Description, Exported, Units, Cost_Code, Category, Class, Chargeout_Level, PayID, Rate
FROM tblTimeEntry
WHERE (Employee LIKE ?) AND (Period_End_Date = ?)
ORDER BY [Date]

I then get my Data by the following:

' Select Data Based upon Current Week Ending and Employee ID
daUserData.SelectCommand.Parameters.Add("@Employee ", OleDbType.Char.Char, 10) daUserData.SelectCommand.Parameters.Add("@MyDateFi eld ", OleDbType.Date) daUserData.SelectCommand.Parameters(0).Value = strUserID
daUserData.SelectCommand.Parameters(1).Value = WeekEndDate
daUserData.Fill(DsUserData.tblTimeEntry)

with the 'date' variable WeekEndDate I choose a 'specific' date.

What I'd like to know, is what do I use as a 'global' search for ALL dates
using the above?

"%" and "*" of course do not work as I have to search a 'DATE'.

Anyone know?

Thanks

Toby

Jul 21 '05 #2
On Sat, 8 Nov 2003 23:12:44 -0500, in microsoft.public.data.ado you wrote:
You cannot use any wildcards for the dates. What you could do here is to use
SQL statement without date condition or use doubled condition for the date
daUserData.SelectCommand.Parameters(1).Value = WeekStartDate
daUserData.SelectCommand.Parameters(2).Value = WeekEndDate


Okay... I recall seeing this start-end date once. But didn't realize that it
was my only option.

Thanks!

I'll take it from here on!

Toby
Jul 21 '05 #3

"Val Mazur" <gr******@hotmail.com> wrote in message
news:Oy*************@TK2MSFTNGP10.phx.gbl...
Hi Toby,

You cannot use any wildcards for the dates. What you could do here is to use SQL statement without date condition or use doubled condition for the date
and pass range of the dates, which basically covers everything. Something
like

SELECT ID, Employee, [Date], Period_End_Date, Job, Description,
Exported,
Units, Cost_Code, Category, Class, Chargeout_Level, PayID, Rate
FROM tblTimeEntry
WHERE (Employee LIKE ?) AND Period_End_Date >= ? AND Period_End_Date <= ?
ORDER BY [Date]


If your SQL dialect supports it, consider changing the two tests for the
date criteria to a single test using the BETWEEN clause. Something like
this :

AND Period_End_Date BETWEEN ? AND ?

regards
roy fine


Jul 21 '05 #4
With Deft Fingers, "Roy Fine" <rl****@twt.obfuscate.net> wrote:
If your SQL dialect supports it, consider changing the two tests for the
date criteria to a single test using the BETWEEN clause. Something like
I'm using OLE and an Access DB file.
AND Period_End_Date BETWEEN ? AND ?


I'll see if this works too.

Thanks!

Toby
Jul 21 '05 #5
Hi,

Yes, it supports BETWEEN

--
Val Mazur
Microsoft MVP
Check Virus Alert, stay updated
http://www.microsoft.com/security/incident/blast.asp
"Toby" <pl****@PostTo.NGs> wrote in message
news:1r********************************@4ax.com...
With Deft Fingers, "Roy Fine" <rl****@twt.obfuscate.net> wrote:
If your SQL dialect supports it, consider changing the two tests for the
date criteria to a single test using the BETWEEN clause. Something like


I'm using OLE and an Access DB file.
AND Period_End_Date BETWEEN ? AND ?


I'll see if this works too.

Thanks!

Toby

Jul 21 '05 #6
>Yes, it supports BETWEEN

What I found interested (not sure if this is correct)... is that now with the
WeekStart and WeekEnd search... my loading of the application has increased (5
seconds or so out of 10 normally).

Would this be 'typical'?

Toby
Jul 21 '05 #7
Hi Toby,

If you do not have indexes created for those fields, then yes, you could
expect it. You should build indexes on a fields, involved into search by
WHERE clause

--
Val Mazur
Microsoft MVP
Check Virus Alert, stay updated
http://www.microsoft.com/security/incident/blast.asp
"Toby" <pl****@PostTo.NGs> wrote in message
news:v1********************************@4ax.com...
Yes, it supports BETWEEN
What I found interested (not sure if this is correct)... is that now with

the WeekStart and WeekEnd search... my loading of the application has increased (5 seconds or so out of 10 normally).

Would this be 'typical'?

Toby

Jul 21 '05 #8
>If you do not have indexes created for those fields, then yes, you could
expect it. You should build indexes on a fields, involved into search by
WHERE clause


Indexes? Hmmm... not sure by what you mean.

Sorry... I've only been using DBs for about 1-1/2 months now. And while I've
learnt a lot... I'm still out of my depth here sometimes :(

Toby
Jul 21 '05 #9
Hi,

Index allows you to boost selection from the table. When you create index,
for the specific field(s), then database maintains it to provide faster
search. I would suggest you to read about databases structure and how to
create indexes. This is not a five minutes topic. If you do not create
appropriate indexes, then you should expect slow selection from the database

--
Val Mazur
Microsoft MVP
Check Virus Alert, stay updated
http://www.microsoft.com/security/incident/blast.asp
"Toby" <pl****@PostTo.NGs> wrote in message
news:pq********************************@4ax.com...
If you do not have indexes created for those fields, then yes, you could
expect it. You should build indexes on a fields, involved into search by
WHERE clause
Indexes? Hmmm... not sure by what you mean.

Sorry... I've only been using DBs for about 1-1/2 months now. And while

I've learnt a lot... I'm still out of my depth here sometimes :(

Toby

Jul 21 '05 #10
VERY GOOD advice Val!

I would only add that if one creates too many indexes, additions, inserts,
and update ALL suffer.

roy fine
"Val Mazur" <gr******@hotmail.com> wrote in message
news:uc**************@TK2MSFTNGP12.phx.gbl...
Hi,

Index allows you to boost selection from the table. When you create index,
for the specific field(s), then database maintains it to provide faster
search. I would suggest you to read about databases structure and how to
create indexes. This is not a five minutes topic. If you do not create
appropriate indexes, then you should expect slow selection from the database
--
Val Mazur
Microsoft MVP
Check Virus Alert, stay updated
http://www.microsoft.com/security/incident/blast.asp
"Toby" <pl****@PostTo.NGs> wrote in message
news:pq********************************@4ax.com...
If you do not have indexes created for those fields, then yes, you couldexpect it. You should build indexes on a fields, involved into search byWHERE clause


Indexes? Hmmm... not sure by what you mean.

Sorry... I've only been using DBs for about 1-1/2 months now. And while

I've
learnt a lot... I'm still out of my depth here sometimes :(

Toby


Jul 21 '05 #11
Yes, that is true. This is why I wrote that it is not a five minute topic

--
Val Mazur
Microsoft MVP
Check Virus Alert, stay updated
http://www.microsoft.com/security/incident/blast.asp
"Roy Fine" <rl****@twt.obfuscate.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
VERY GOOD advice Val!

I would only add that if one creates too many indexes, additions, inserts,
and update ALL suffer.

roy fine
"Val Mazur" <gr******@hotmail.com> wrote in message
news:uc**************@TK2MSFTNGP12.phx.gbl...
Hi,

Index allows you to boost selection from the table. When you create index,
for the specific field(s), then database maintains it to provide faster
search. I would suggest you to read about databases structure and how to
create indexes. This is not a five minutes topic. If you do not create
appropriate indexes, then you should expect slow selection from the

database

--
Val Mazur
Microsoft MVP
Check Virus Alert, stay updated
http://www.microsoft.com/security/incident/blast.asp
"Toby" <pl****@PostTo.NGs> wrote in message
news:pq********************************@4ax.com...
>If you do not have indexes created for those fields, then yes, you could >expect it. You should build indexes on a fields, involved into search by >WHERE clause

Indexes? Hmmm... not sure by what you mean.

Sorry... I've only been using DBs for about 1-1/2 months now. And

while I've
learnt a lot... I'm still out of my depth here sometimes :(

Toby



Jul 21 '05 #12
Toby,

Without indexes, the database is left to search the entire table for matches
on the Where clause - these are often referred to as FTS or Full Table Scan.
These acceses occur when you select from a single table, and also when you
join two or more tables.

As a general rule of thumb, when you are expecting less than 10% of the rows
to be returned, and where the size of the table is greater than 10 blocks,
indexes have the potential of adding an incredible performance boost.

Consider the problem in searching a table of customers for those records
that have the phone number of 800-555-1212 (US NAN assumed here).

If there are no indexes, and if there are 2,000,000 rows in the database,
and each row is on average 320 bytes, and if you expect only one or two rows
in the resultset, the database reads all 2,000,000 rows, comparing each
phone number to the value above. If we assume a block size of 8k, then we
may be able to squeeze 25 or so records into a block. To read the 2,000,000
rows would require 87,000 or so disk reads. (**disk reads are VERY slow**)

This would result in a substantial amount of compute resources to do the
2,000,000 string compares, as well as an incredible amount of disk activity
if we assume that the customer table was not already in memory (650 mbytes
plus some for overhead of segment headers, etc) - and all that work for just
a couple of records. One solution would be an index on phonenumber. An
index is a separate segment, very much related to the associated table, and
is organized in a structure that is optimized for seaches, especially
searches that involve a test for equality (or inequality). In the simplest
case (excluding IOTs, clusters, and composite indexes) the index is
typically a balanced, sorted tree structure.

The root of the tree is some value near the middle, and the root has two
nodes - a left node and a right node. The left and right nodes are for all
values that less than the root value and greater than the root value
respectively. Each of these left and right nodes is again a distinct node
that is the root for the structure below it, each with a left and right
node, and so on until you get to the terminal nodes, which are typically
called leaf nodes. A leaf node contains a value (a phone number is our
case) and a block and offset pointer into the associated table.

While this is an absurd simplification, the concept is quite solid. The
subject is treated quite well by Knuth in his Vol I, The Art of Computer
Programming-Fundamental Algorithms. The actual implementation is platform
specific, and well optimized for block (or multiblock) disk reads (i.e. a
node may not be atomic as implied, rather a block of nodes - or as many
values as would fit in a block) - mainly because indexes are there to
minimize disk reads (although other benefits include supporting constraints
and sorting).

Back to our problem of above; using the index, the records that satisfy the
where clause might be accessed in as few as a 6 or so disk reads. It is the
ratio of the disk reads using an index to the disk reads of a FTS that we
might use to measure the effectiveness of the index. But indexes do not
alway help! Consider what happens when we write the select statement such
that it returns 1,000,000 records (i.e. all of the records in a particular
state or country) The worse case for the FTS would be 87,000 disk reads.
But with the index, we could easily exceed that count several times if the
distibution of the items in the data table were dramatically different from
the distribution of the keys in the index block (i.e. the index is sorted by
state or country, the table data is sorted by person's last name, and no two
adjacent index leaf nodes point to records in the same block in the data
table). This is a case where the index actually slows performance - and a
FTS is a LOT quicker.

As Val said, this subject is not a 5 minute topic - and moreover, it is not
about "to index or not to index", it is about appropriate indexes - based on
the data and how it will be accessed (select, update, insert, etc). Hang in
there -- while this stuff may seem overly complicated at first, it's just
way tooooo much fun to even consider doing anything else... :)

regards
roy fine
"Toby" <pl****@PostTo.NGs> wrote in message
news:pq********************************@4ax.com...
If you do not have indexes created for those fields, then yes, you could
expect it. You should build indexes on a fields, involved into search by
WHERE clause
Indexes? Hmmm... not sure by what you mean.

Sorry... I've only been using DBs for about 1-1/2 months now. And while

I've learnt a lot... I'm still out of my depth here sometimes :(

Toby

Jul 21 '05 #13
With Deft Fingers, "Val Mazur" <gr******@hotmail.com> wrote:
Index allows you to boost selection from the table. When you create index,
for the specific field(s), then database maintains it to provide faster
.... sort of like a search of the original DB... but now only a fraction of the
size? (and of course, on the Client side of the line)
search. I would suggest you to read about databases structure and how to
create indexes. This is not a five minutes topic. If you do not create


Hmmm... I've David Sceppa's ADO.NET book... and a quick glance shows there is
nothing in the Index on 'indexes'. I'll have to dig into this some more.

Thanks!

Toby
Jul 21 '05 #14
>Without indexes, the database is left to search the entire table for matches
on the Where clause - these are often referred to as FTS or Full Table Scan.
Okay.
ratio of the disk reads using an index to the disk reads of a FTS that we
might use to measure the effectiveness of the index. But indexes do not
alway help! Consider what happens when we write the select statement such
that it returns 1,000,000 records (i.e. all of the records in a particular
I understand. Currently I'm only reading about 20,000 to 30,000 records (not
in the Millions). So for me, it's probably not an issue.
As Val said, this subject is not a 5 minute topic - and moreover, it is not
about "to index or not to index", it is about appropriate indexes - based on


Points taken. I'll try finding if I've anything on "Indexes" in my books
(can't see anything yet)... if I do, I'll probably try it out to see IF in my
case it is worth it or not.

Thanks for the info!

Toby
Jul 21 '05 #15

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

Similar topics

4
by: Stewart Allen | last post by:
I'm trying to filter a table that has 2 date fields, the first date will always have a value but the second will only occasionally has a value. Each date field also has a corresponding text field...
33
by: MLH | last post by:
I've read some posts indicating that having tons of GV's in an Access app is a bad idea. Personally, I love GVs and I use them (possibly abuse them) all the time for everything imaginable - have...
7
by: Adam | last post by:
Im trying to add an httphandler for all *.sgf file extensions. I have developed the handler, 1. installed it into the gac 2. added it to the machine.config: <httpHandlers> <add verb="*"...
0
by: Rick Hein | last post by:
I've got a problem with an app I've been working on, the Caching object and events not firing correctly. In a nutshell: When I'm debugging, and I set a breakpoint in the removed item call back, the...
14
by: Toby | last post by:
I've a DataAdapter with: SELECT ID, Employee, , Period_End_Date, Job, Description, Exported, Units, Cost_Code, Category, Class, Chargeout_Level, PayID, Rate FROM tblTimeEntry WHERE ...
2
by: JohnT | last post by:
Okay... I'm using VB.net (2003) and I am accessing an MS Access DB file. I have two DataAdapters that I use to search for specific info. The two of them are similar except one is a Date, the...
4
by: Mark Olbert | last post by:
I have several ASP.NET 1.1 websites where I centralized a read-only dataset (i.e., one which no web page ever changed) and its associated SqlDataAdapters. In 2.0 I noticed that the Global.asax...
12
by: Rob Meade | last post by:
Hi all, Ok - I've come from a 1.1 background - and previously I've never had any problem with doing this: Response.Write (Session("MyDate").ToString("dd/MM/yyyy")) So, I might get this for...
6
by: fonzie | last post by:
Is there any way to include two unbound text boxes (for a start date and end date) to a filter-by-form? The users may want to filter by several different fields and they may want to include a date...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
jinu1996
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...
0
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...

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.