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的值应该怎么写?
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的值应该怎么写?
查询出来后
在messagebox里面去显示bgTime和etTime
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();
这个只能显示最后一条数据的begintime和endtime
欢迎光临我的博客