条件在哪里的问题 [英] problem in where condition

查看:67
本文介绍了条件在哪里的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我在查询中的where条件上遇到了一些问题.
下面的代码可以正常工作,直到从表中选择*.
但是只要我将where条件设为,就会看到一个空白图表.
因此,问题不在于图形,而在于查询.
在这里,out_table是表名.
我无法弄清楚.
请帮忙.

代码:

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:

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");



:对不起,我没有意识到我发布了不完整的代码.这是完整的代码.
我从日期时间选择器中获取日期并将其存储为字符串.可以吗?



: 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.

推荐答案

您的代码似乎不完整....

请使用介于之间以进行更好的日期比较...

关于
Your code seems to be incomplete....

please use between for better date comparisons...

Regards


u没有发布整个查询..
如果您想在两个日期之间检索数据
那么这就是执行此操作的方法之一.

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..

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

>
或者只需使用BETWEEN
希望对您有帮助.


Or simply use BETWEEN
hope this help you.


这篇关于条件在哪里的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆