Solved

why am I getting too many items in dataset

Posted on 2014-02-06
5
152 Views
Last Modified: 2014-02-07
sqlstring2 = "Select * from EmployeeAccumInfo where (WORKDATE >  '" & dateString & " ' and WORKDATE < '" & datestring2 & "') ORDER BY ID ASC    "
                Dim Dad As OleDbDataAdapter = New OleDbDataAdapter(sqlstring2, Con)
                Con.Open()
                Dim Dst3 As DataSet = New DataSet
                Dad.Fill(Dst3)
                Con.Close()

workdate is every date in the month of Feb.
dateString = 1/31/2014 and datestring2 = 2/7/2014  These are strings in table and code
when I run the query Dst3 has every date in the table.
How can I get a date > than 2/7/2014????????  it is totally illogical to return every date.

thanks

gary
0
Comment
Question by:javagair
  • 3
  • 2
5 Comments
 
LVL 12

Expert Comment

by:ktaczala
ID: 39840964
Try This:
sqlstring2 = "Select * from EmployeeAccumInfo where (WORKDATE > "'" & dateString & "'" and WORKDATE < "'" & datestring2 & "'") ORDER BY ID ASC"

sqlstring2 should look like this"
"Select * from EmployeeAccumInfo where (WORKDATE > '1/31/2014' and WORKDATE < '2/7/2014') ORDER BY ID ASC"
0
 
LVL 12

Expert Comment

by:ktaczala
ID: 39840965
You know that you are excluding the 2 dates your using, right?
0
 
LVL 12

Accepted Solution

by:
ktaczala earned 500 total points
ID: 39840971
Or try this

sqlstring2 = "Select * from EmployeeAccumInfo where (WORKDATE > "'" & dateString & "'") and (WORKDATE < "'" & datestring2 & "'") ORDER BY ID ASC"

sqlstring2 should look like this"
"Select * from EmployeeAccumInfo where (WORKDATE > '1/31/2014') and (WORKDATE < '2/7/2014') ORDER BY ID ASC"
0
 

Author Comment

by:javagair
ID: 39842666
yes I know that I was excluding those two dates.
The problem turned out to be because they are strings and one is created as a short by the vb.net code it is actually  01/01/2014
and the other is a date conversation to  string which turned out as 1/1/2014
So the query just goes down the columns looking for something that isn't there

I changed the tostring code to use:  dateString = DTPbegin.Value.ToString("MM/dd/yyyy") everywhere
and got rid of the code:    dateString = dt.ToShortDateString()

now everything works wonderful.  Sometimes we look at things as people do and not as computers do.

gary
0
 

Author Closing Comment

by:javagair
ID: 39842671
awarding points because the question is answered by myself, but kataczala gave an answer that could have been right if I knew what I was asking.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now