Solved

why am I getting too many items in dataset

Posted on 2014-02-06
5
148 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
What is MicroStrategy.NET? 2 44
.NET Error 7 42
Why, and when, to use Windows Workflow 1 17
Set form below another form 3 25
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

12 Experts available now in Live!

Get 1:1 Help Now