Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,
I am having some problem with the where condition in a query.
the code below is working fine, until its select * from table.
but as soon as I put the where condition, I saw a blank graph.
thus, the problem is not with the graph, but with the query.
here, out_table is the table name.
I am not able to figure it out.
Please help.

code:
C#
string dt_start = dateTimePicker1.Value.ToShortDateString();
 string dt_end = dateTimePicker2.Value.ToShortDateString();

string mySelectQuery2 = "Select * from " + in_table + " WHERE Date Between " + dt_start + " and " + dt_end + " ";
OleDbDataAdapter da2 = new OleDbDataAdapter(mySelectQuery2, con);
            DataSet ds2 = new DataSet();
             da2.Fill(ds2, in_table);
            DataView firstView2 = new DataView(ds2.Tables[0]);
         Chart1.Series[1].Points.DataBindXY(firstView2, "ID", firstView2, "Close");


EDIT:: sorry i didn't realize that I posted incomplete code. this is the full code.
I am taking the dates from a date time picker and storing it as string. is it ok?
updated the code with this code too.
Posted
Updated 30-Mar-12 17:44pm
v3

Your code seems to be incomplete....

please use between for better date comparisons...

Regards
 
Share this answer
 
u didnt post the whole query..
if u want to retrieve data between two date
then here is one of the way to do this..

SQL
select * from table_name where date>='"+ Start_Date +"' AND Date<='"+ End_Date +"';

Or simply use BETWEEN
hope this help you.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900