select txt from table1 where date=getdate()

解决方案 »

  1.   

    select text from table where date='2004:4:30'
      

  2.   

    select 文本字段 from 表 where time='2004-4-30'
      

  3.   

    string date=textbox.Text.Trim();//如果输入查询时间
    SqlConnection conn=new SqlConnection(connt_str);
    string sql="select txt from table where date='"+date+"'";
    string text=null;
    byte[] mybyte=new byte[1024];//设置字符缓冲区
    try{
      conn.Open();
      SqlCommand comm=new SqlCommand(sql,conn);
      SqlDataReader dr=comm.ExecuteReader();
      if(dr.Read()){
          text=dr["txt"].ToString();
         }
       dr.Close();
       conn.Close();  // 完成从数据库读出查询内容到text中;
      }
     catch(Exception ee){
       MessageBox.Show(ee.Message);
       }
     /////////////////////
     以下是把text中的内容读到一个自己建立的txt的文本文件中
    ///当然这个可以自己选择时候要这么做,因为看楼主好象是要这个意思/
    ////////////////////////
    // 当然以下内容完全可以不要,可以直接把text中的内容显示在richtextbox中,
    //不过如果要以日志等形式保留的话,以下可以参考下
     try{
       FileStream fs=new FileStream(filename,FileAccess.Write,FileMode.CreateNew);
       mybyte=System.Text.Encoding.Ascii.GetByte(text);
       fs.Read(mybyte);  //把缓冲区内容读入文件流
       fs.Clsoe(); 
      }
      catch(Exception ee){
       MessageBox.Show(ee.Message);
      }                                            wish u good luck
                                                    Greatsft
      

  4.   

    Sqlcommand cmd=New Sqlcommand("select time from table" ,this.con);
    this.con.open();
    SqlDataReader reader= reader.ExecuteReader ( );while(reader.Read())

    this.Listbox1.Items.Add(reader.GetDataTime(0));
    }
    this.reader.close();
    this.con.close();private void Listbox1_SelectedIndexChanged(object sender, System.EventArgs e)
    {
    DataTime time=Convert.ToDataTime(Listbox1.SelectedItem)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^接下来 把time当为参数穿给下一条语句