Home > Database > Mysql Tutorial > C# access SQL查询日期的代码!

C# access SQL查询日期的代码!

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:17:15
Original
1652 people have browsed it

C# access SQL 查询 日期 的 代码 ! 注意:ACCESS里面Date类型为形如:2010-4-8 的长 日期 类型 private void FindButton_Click(object sender, EventArgs e) { OleDbConnection con = new OleDbConnection(dbConnetion.connetion);//在dbConnetion.cs中有

C# access SQL查询日期代码

注意:ACCESS里面Date类型为形如:2010-4-8 的长日期类型

private void FindButton_Click(object sender, EventArgs e)
        {
            OleDbConnection con = new OleDbConnection(dbConnetion.connetion);//在dbConnetion.cs中有专门的数据打开类
            string cmdStr;
            if(Hour==0)
            {
                cmdStr = "select * from MeteorologyData where Date=" + this.FindDate.ToOADate();
            
            }
            else
            {
                cmdStr = "select * from MeteorologyData where Date=" + this.FindDate.ToOADate() + " and Time=" + Hour; 
            }
            con.Open();

            OleDbDataAdapter adp = new OleDbDataAdapter(cmdStr, con);
            ds = new DataSet();
            ds.Clear();   
            adp.Fill(ds);
                      string[] mytitle ={ "日期", "时间段", "有效能见度", "海面能见度", "天气现象", "总云量", "中低云量和", "低云量", "云状编码", "云状", "风向", "风速", "气温", "绝对湿度", "相对湿度", "露点", "本站气压", "海平面气压", "降水量", "波浪", "记录人编号" };
           for (int i = 0; i             {
                   ds.Tables[0].Columns[i].ColumnName = mytitle[i];
            }

           dataGridView1.DataSource = ds.Tables[0].DefaultView;      
          
           // dataGridView1.Capture = "共有" + ds.Tables[0].Rows.Count.ToString()+ "条记录";
            con.Close();
        }

 


文章:C# access SQL查询日期代码
地址:http://www.verydemo.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Access error using alias
From 1970-01-01 08:00:00
0
0
0
Single module access
From 1970-01-01 08:00:00
0
0
0
About Mac MAMP PRO deploy thinkphp5.1 access 404
From 1970-01-01 08:00:00
0
0
0
My access page reports 403
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template