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的值应该怎么写?

解决方案 »

  1.   

    select bgTime=beginTime,etTime=endTime ,...,..from CheckerInfo where begintime<=getdate() and endtime>=getdate();
    查询出来后
    在messagebox里面去显示bgTime和etTime
      

  2.   


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

  3.   


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

  4.   

    恩 应该把MessageBox放到while里面
      

  5.   

    你的结贴率比较低呀。你把DataTable里的值读出来放进去就可以。
    欢迎光临我的博客