社区
C#
帖子详情
winform中的查询功能
q198708wyp
2011-05-23 02:16:21
起始时间 结束时间 查询 并且在列表里面显示出来 怎们实现,代码
...全文
289
16
打赏
收藏
winform中的查询功能
起始时间 结束时间 查询 并且在列表里面显示出来 怎们实现,代码
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
16 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
昵称不能为空噢噢噢噢
2011-05-24
打赏
举报
回复
sqlquery=@"select * from riqi where date>=COVERT(DATE,'"+BeginTime+"',120) and date<=COVERT(DATE,'"+EndTime+"',120)"
q198708wyp
2011-05-24
打赏
举报
回复
是呀 DateTime sqlquery=@"select * from riqi where date>'"+BeginTime+"' and date<'"+EndTime+"'";
说是类型转换有问题
错误 2 无法将类型“System.DateTime”隐式转换为“string”
错误 1 无法将类型“string”隐式转换为“System.DateTime”
加我QQ可以么 这样方便点。521070107
昵称不能为空噢噢噢噢
2011-05-24
打赏
举报
回复
[Quote=引用 11 楼 q198708wyp 的回复:]
private void button2_Click(object sender, EventArgs e)
{
string BeginTime=this.dateTimePicker1.Text.ToString();
string EndTime=this.dateTimePicker2.Text.ToString();
string sqlquery=@"s……
[/Quote]
还有,要加改一下查询语句啊,
string sqlquery=@"select * from riqi where
date>='"+BeginTime+"'
and
date<='"+EndTime+"'";
昵称不能为空噢噢噢噢
2011-05-24
打赏
举报
回复
[Quote=引用 11 楼 q198708wyp 的回复:]
private void button2_Click(object sender, EventArgs e)
{
string BeginTime=this.dateTimePicker1.Text.ToString();
string EndTime=this.dateTimePicker2.Text.ToString();
string sqlquery=@"s……
[/Quote]注意你的查询时间啊,不符合条件的怎么能查出来呢,看看是不是这样
昵称不能为空噢噢噢噢
2011-05-24
打赏
举报
回复
[Quote=引用 11 楼 q198708wyp 的回复:]
private void button2_Click(object sender, EventArgs e)
{
string BeginTime=this.dateTimePicker1.Text.ToString();
string EndTime=this.dateTimePicker2.Text.ToString();
string sqlquery=@"s……
[/Quote]那显示出来什么呀?
q198708wyp
2011-05-24
打赏
举报
回复
private void button2_Click(object sender, EventArgs e)
{
string BeginTime=this.dateTimePicker1.Text.ToString();
string EndTime=this.dateTimePicker2.Text.ToString();
string sqlquery=@"select * from riqi where date>BeginTime and date<EndTime";
SqlConnection scc=new SqlConnection("Data Source=.;Initial Catalog=login;Integrated Security=True");
SqlCommand scm=new SqlCommand();
scm.CommandType=CommandType.Text;
scm.CommandText=sqlquery;
SqlDataAdapter sda=new SqlDataAdapter();
sda.SelectCommand=scm;
DataSet ds=new DataSet();
sda.Fill(ds);
dataGridView1.DataSource=ds.Tables[0].DefaultView;
}
能正常运行,但是点击查询按钮的时候不能出来正常的结果。怎么解决呀,八楼,和其他高手帮忙看下。
Bo217
2011-05-23
打赏
举报
回复
[Quote=引用 8 楼 hhqsy 的回复:]
string sqlquery = @"select * from riqi where date>2011-5-12 and date<2011-5-22";
SqlConnection scc = new SqlConnection("Data Source=.;Initial Catalog=log;Integrated Security=True");
SqlCommand ……
[/Quote]
顶一下
rabbitlzx
2011-05-23
打赏
举报
回复
[Quote=引用 7 楼 q198708wyp 的回复:]
不要数据库的查询语句,要button控件下的事件代码。和listbox空间下的代码。
[/Quote]底层就是点了button后 到数据库去查询,然后将返回结果绑定到UI的控件上(listbox)
昵称不能为空噢噢噢噢
2011-05-23
打赏
举报
回复
string sqlquery = @"select * from riqi where date>2011-5-12 and date<2011-5-22";
SqlConnection scc = new SqlConnection("Data Source=.;Initial Catalog=log;Integrated Security=True");
SqlCommand scm= new SqlCommand();
scm.Connection = scc;
scm.CommandType = CommandType.Text;
scm.CommandText = sqlquery;
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = scm;
DataSet ds = new DataSet();
sda.Fill(ds);
dataGridView1.DataSource = ds.Tables[0].DefaultView;
q198708wyp
2011-05-23
打赏
举报
回复
不要数据库的查询语句,要button控件下的事件代码。和listbox空间下的代码。
xixihaha_2011_098
2011-05-23
打赏
举报
回复
SELECT 列 FROM 表 WHERE 列名 BETWEEN 起始时间 AND 结束时间
SELECT 列 FROM 表 WHERE 时间 > 起始时间 and 时间 < 结束时间
都可以
Arestain
2011-05-23
打赏
举报
回复
SELECT 列
FROM 表
WHERE 列名 BETWEEN 起始时间 AND 结束时间
q198708wyp
2011-05-23
打赏
举报
回复
200102,我是刚刚学起winform 以前是做C++的 麻烦你们说的详细点好么?再次感谢
cjh200102
2011-05-23
打赏
举报
回复
楼上已经写得够详细了。
楼主莫不是自己一点不想写。
q198708wyp
2011-05-23
打赏
举报
回复
我的数据库名字是log 连接的表名字是riqi,查询语句
select * from riqi where date>2011-5-12 and date<2011-5-22.
你把代码 写上,再麻烦一下高手,写好我给你满分
rabbitlzx
2011-05-23
打赏
举报
回复
form上放一个datagridview
查询语句 select <你要查询的> from xxx when 时间 > 起始时间 and 时间 < 结束时间
using (SqlCommand cmd = new SqlCommand())
{
cmd.Connection = 连接对象;
cmd.CommandType = CommandType.Text;
cmd.CommandText = 查询语句;
然后将查询结果存到DataTable中,
DataTable dt = new DataTable();
SqlDataAdapter dapt = new SqlDataAdapter(cmd);
dapt.Fill(dt);
关联datagridview和查询结果 datagridview1.DataSource = dt;
winform
combobox 模糊
查询
winform
combobox 模糊
查询
winForm
文本框检索
功能
模仿baidu搜索框,
winform
组件
C#
Winform
图书管理系统
该管理系统采用的开发语言环境是VS2017+SQL Server 2008/2012 ,C/S架构开发的一套
Winform
窗体版本的管理系统。该系统含有按钮控件、输入控件、容器控件、布局控件、数据控件等常用控件的介绍及使用。该系统含有主窗体子窗体间的传值,表格控件及树形控件的数据展示、MDI窗体的使用等。系统
功能
:图书资料管理、读者资料管理、用户资料管理、图书借阅管理(借阅、归还、续接、超期、挂失)、系统参数设置、
查询
统计
WinForm
信息
查询
WinForm
信息
查询
集合源码
功能
介绍:包括了QQ在线
查询
,天气预报
查询
,手机归属
查询
,火车时刻,IP地址,快递
查询
,身份证
查询
,飞机时刻
查询
的
功能
C#
winform
开发的一个连接mysql的小工具,实现简单的增删改查
功能
,并通过chart图表控件直观的显示数据。
这是一个C#
winform
开发的一个连接mysql的小工具,实现简单的增删改查
功能
,并通过chart图表控件直观的显示数据。 具体chart控件的操作可以看下面大神的讲解 https://blog.csdn.net/daisy0923/article/details/73325681/
C#
110,535
社区成员
642,577
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章