希望高手指点一二,十分的感谢。

fannylonglongago 2011-08-16 11:06:05
string sql= "select * from CheckerInfo where begintime<=getdate() and endtime>=getdate()";
System.Data.DataTable con = new System.Data.DataTable();
con = data.GetDataSet(sql);
if (con.Rows.Count > 0)
{
MessageBox.Show(sql.Trim(),"温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
1、想让messagebox显示sql值,而不是显示select * from CheckerInfo where begintime<=getdate() and endtime>=getdate();
2、如果让messagebox显示sql中的begintime及endtime的值应该怎么写?
...全文
101 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
fannylonglongago 2011-09-09
  • 打赏
  • 举报
回复
楼上的对。
zhang_debug 2011-08-16
  • 打赏
  • 举报
回复
恩 应该把MessageBox放到while里面
hui_play 2011-08-16
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 xingxingbanyue 的回复:]
C# code


string str_begin="";
string str_end="";
SqlConnection conn = new SqlConnection("连接串");
conn.Open();
string sql = "select * from CheckerInfo where begintime<=getdate() and endtime>=ge……
[/Quote]

这个只能显示最后一条数据的begintime和endtime

LMAOhuaNL 2011-08-16
  • 打赏
  • 举报
回复
楼上已经给你写了出来了
xingxingbanyue 2011-08-16
  • 打赏
  • 举报
回复

string str_begin="";
string str_end="";
SqlConnection conn = new SqlConnection("连接串");
conn.Open();
string sql = "select * from CheckerInfo where begintime<=getdate() and endtime>=getdate()";
SqlCommand comm=new SqlCommand (sql,conn);
SqlDataReader dr = comm.ExecuteReader();
while (dr.Read())
{
str_begin = Convert.ToString(dr["begintime"]);
str_end = Convert.ToString(dr["endtime"]);
}
dr.Close();
MessageBox.Show("BeginTime="+str_begin+" EndTime="+str_end,"温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
conn.Close();
LMAOhuaNL 2011-08-16
  • 打赏
  • 举报
回复
select bgTime=beginTime,etTime=endTime ,...,..from CheckerInfo where begintime<=getdate() and endtime>=getdate();


查询出来后
在messagebox里面去显示bgTime和etTime
jquerywww 2011-08-16
  • 打赏
  • 举报
回复
你的结贴率比较低呀。

你把DataTable里的值读出来放进去就可以。


欢迎光临我的博客
半瓶神仙水 2011-08-16
  • 打赏
  • 举报
回复
照二楼的做吧

110,524

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧