您好,欢迎来到华佗小知识。
搜索
您的当前位置:首页comBox绑定SQLServer数据库中时间字段中的不重复的年份

comBox绑定SQLServer数据库中时间字段中的不重复的年份

来源:华佗小知识


关于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.GetRec

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

  }

Copyright © 2019- huatuo0.cn 版权所有 湘ICP备2023017654号-2

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务