如何编写一个小程序,只要输入时间段,就能从数据库导出数据。

时间:2022-04-23 11:25:13
如何编写一个小程序,只要输入时间段,就能从数据库导出数据。数据库中的SQL查询语句已经写好,求小程序编写。。。

15 个解决方案

#1


该回复于2012-08-01 13:07:10被版主删除

#2


这个不难啊,我一民工级的也能说个大概吧:
1、建一个WinForm,托一个文本框用来输入日期范围,一个按钮查询
2、定义个字符串,将SQL与日期范围重新组织成一个SQL语句
3、用ADO.NET代码连接数据,执行SQL语句,完成

#3


LZ的意思是按照用户输入的时间段来查询么?

#4


把你输入的时间传入SQL语句里不就行了吗

#5


引用 3 楼  的回复:
LZ的意思是按照用户输入的时间段来查询么?


是的

#6


引用 4 楼  的回复:
把你输入的时间传入SQL语句里不就行了吗



就是不会写啊。。。。所以才问嘛

#7


SELECT * FROM 表名 WHERE条件 AND time BETWEEN 时间1 AND 时间2
这个是sql语句的伪代码,想知道更详细的代码的话,把你的数据表发过来看看。

#8


问题解决了没有呢?

#9


引用 8 楼  的回复:
问题解决了没有呢?


还没有啊,

SQL语句是这样的
if object_id('tempdb.dbo.#t') is not null drop table #t
select * into #t from
(
select mer_id,mer_type
from t_mer_infor
)t
---广东
select t_id 类别ID号,count(*) 交易笔数,sum(liquidateAmt) 交易金额
from s_trans_record a,t_mer_type b,#t
where a.MerId = #t.mer_id
and b.mer_type = #t.mer_type
and left(CtrPostDate,6) ='201103'
group by t_id
order by t_id

---汕头
select t_id 类别ID号,count(*) 交易笔数,sum(liquidateAmt) 交易金额
from s_trans_record a,card_st.dbo.t_mer_type b,card_st.dbo.t_mer_infor c
where a.MerId = c.mer_id
and b.mer_type = c.mer_type
and left(CtrPostDate,6)= '201103'
group by t_id
order by t_id


如何可以每个月2号自动将数据导出成excle表。

#10


引用 9 楼  的回复:
引用 8 楼  的回复:

问题解决了没有呢?


还没有啊,

SQL语句是这样的
if object_id('tempdb.dbo.#t') is not null drop table #t
select * into #t from
(
select mer_id,mer_type
from t_mer_infor
)t
---广东
select t_id ……

 如何可以每个月2号自动将上个月的数据导出成excle表。

#11


作业啊....

#12


sql 里有个作业的。。俺不喜欢看书。。具体不说了。

#13


LINQ TO SQL

#14


SELECT * FROM table1 WHERE 条件 AND time BETWEEN time1 AND time2
就行了嘛~

#15


select KeyID, LockID,Operator,LockType,OperationTime,TicketID
from  T_KeyOperation 
where StartTime > datetime(\'" + startTime.ToString("s") + "\') and EndTime < datetime (\'" + endTime.ToString("s") + "\')
类似的代码

#1


该回复于2012-08-01 13:07:10被版主删除

#2


这个不难啊,我一民工级的也能说个大概吧:
1、建一个WinForm,托一个文本框用来输入日期范围,一个按钮查询
2、定义个字符串,将SQL与日期范围重新组织成一个SQL语句
3、用ADO.NET代码连接数据,执行SQL语句,完成

#3


LZ的意思是按照用户输入的时间段来查询么?

#4


把你输入的时间传入SQL语句里不就行了吗

#5


引用 3 楼  的回复:
LZ的意思是按照用户输入的时间段来查询么?


是的

#6


引用 4 楼  的回复:
把你输入的时间传入SQL语句里不就行了吗



就是不会写啊。。。。所以才问嘛

#7


SELECT * FROM 表名 WHERE条件 AND time BETWEEN 时间1 AND 时间2
这个是sql语句的伪代码,想知道更详细的代码的话,把你的数据表发过来看看。

#8


问题解决了没有呢?

#9


引用 8 楼  的回复:
问题解决了没有呢?


还没有啊,

SQL语句是这样的
if object_id('tempdb.dbo.#t') is not null drop table #t
select * into #t from
(
select mer_id,mer_type
from t_mer_infor
)t
---广东
select t_id 类别ID号,count(*) 交易笔数,sum(liquidateAmt) 交易金额
from s_trans_record a,t_mer_type b,#t
where a.MerId = #t.mer_id
and b.mer_type = #t.mer_type
and left(CtrPostDate,6) ='201103'
group by t_id
order by t_id

---汕头
select t_id 类别ID号,count(*) 交易笔数,sum(liquidateAmt) 交易金额
from s_trans_record a,card_st.dbo.t_mer_type b,card_st.dbo.t_mer_infor c
where a.MerId = c.mer_id
and b.mer_type = c.mer_type
and left(CtrPostDate,6)= '201103'
group by t_id
order by t_id


如何可以每个月2号自动将数据导出成excle表。

#10


引用 9 楼  的回复:
引用 8 楼  的回复:

问题解决了没有呢?


还没有啊,

SQL语句是这样的
if object_id('tempdb.dbo.#t') is not null drop table #t
select * into #t from
(
select mer_id,mer_type
from t_mer_infor
)t
---广东
select t_id ……

 如何可以每个月2号自动将上个月的数据导出成excle表。

#11


作业啊....

#12


sql 里有个作业的。。俺不喜欢看书。。具体不说了。

#13


LINQ TO SQL

#14


SELECT * FROM table1 WHERE 条件 AND time BETWEEN time1 AND time2
就行了嘛~

#15


select KeyID, LockID,Operator,LockType,OperationTime,TicketID
from  T_KeyOperation 
where StartTime > datetime(\'" + startTime.ToString("s") + "\') and EndTime < datetime (\'" + endTime.ToString("s") + "\')
类似的代码