展会信息港展会大全

comBox绑定SQL Server数据库中时间字段中的不重复的年份
来源:互联网   发布日期:2016-01-27 15:50:07   浏览:2298次  

导读:关于comBox绑定SQL Server数据库中时间字段中的不重复的年份如下: private void Education_Training_Load(object sender, EventArgs e) { MyDBase DB = new MyDBase(DBUser sserver, DBUse ...

关于comBox绑定SQL Server数据库中时间字段中的不重复的年份如下:

private void Education_Training_Load(object sender, EventArgs e)

{

MyDBase DB = new MyDBase(DBUser.sserver, DBUser.DBName, DBUser.suser, DBUser.spasswd);

DataSet DS = DB.GetRecordset("select distinct (year(date)) as date from education_train ");

if (DS.Tables[0].Rows.Count == 0) return;

comboBox_Year.DataSource = DS.Tables[0];

comboBox_Year.DisplayMember = "date";

comboBox_Year.ValueMember = "date";

comboBox_Year.SelectedIndex = comboBox_Year.Items.Count - 1;//选中最大年份

if (DB.ErrorCode())

{

MessageBox.Show(DB.ErrMessage(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);

return;

}

dataGridView1.DataSource = DS.Tables[0];

DB.DBClose();

}

赞助本站

人工智能实验室

相关热词: 数据库 字段 comBox

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港