?
Solved

why am I getting too many items in dataset

Posted on 2014-02-06
5
Medium Priority
?
159 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1500 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

765 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