Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Заполнение элемента Combobox из БД
- /// </summary>
- /// <param name="cb">Элемент combobox</param>
- /// <param name="cbValueMember">Свойства значения</param>
- /// <param name="cbDisplayMember">Свойство отображения</param>
- /// <param name="FillerName">Имя хранимой процедуры</param>
- /// <param name="FillerTable">Имя таблицы</param>
- public static void GetList(ComboBox cb, string cbValueMember, string cbDisplayMember, string FillerName, string FillerTable)
- {
- using (MySqlConnection Connection = new MySqlConnection(Properties.Settings.Default.DBConnectionString))
- {
- MySqlCommand cmd = new MySqlCommand(FillerName, Connection);
- MySqlDataAdapter da = new MySqlDataAdapter();
- DataSet ds = new DataSet();
- try
- {
- cmd.CommandType = CommandType.StoredProcedure;
- da.SelectCommand = cmd;
- da.Fill(ds, FillerTable);
- cb.DataSource = ds.Tables[FillerTable];
- cb.DisplayMember = cbDisplayMember;
- cb.ValueMember = cbValueMember;
- }
- catch (Exception)
- {
- throw;
- }
- finally
- {
- cmd.Dispose();
- Connection.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement