欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

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

程序员文章站 2022-05-04 17:46:08
...

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