示例#1
0
        public void Load_Depart()
        {
            SqlConnection dBConn = new SqlConnection();

            dBConn.ConnectionString = ConfigurationManager.ConnectionStrings["ConnStr"].ToString();
            dBConn.Open();

            SqlCommand LoadDepart_Cmd = new SqlCommand("SELECT DEPART_NAME FROM DEPARTMENTS", dBConn);

            SqlDataReader LoadDepartReader;

            try
            {
                LoadDepartReader = LoadDepart_Cmd.ExecuteReader();
                while (LoadDepartReader.Read())
                {
                    sAssingedDepartCombo.Items.Add(LoadDepartReader);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            dBConn.Close();
            dBConn.Dispose();
        }
示例#2
0
        public void Fill_dDepartCombo()
        {
            SqlConnection dBConn = new SqlConnection();

            dBConn.ConnectionString = ConfigurationManager.ConnectionStrings["ConnStr"].ToString();
            dDepartCombo.Items.Clear();
            SqlCommand LoadDepart_Cmd = new SqlCommand("SELECT DEPART_NAME FROM DEPARTMENTS", dBConn);

            SqlDataReader LoadDepartReader;

            try
            {
                dBConn.Open();
                LoadDepartReader = LoadDepart_Cmd.ExecuteReader();
                while (LoadDepartReader.Read())
                {
                    string DepartNameFromtbl = LoadDepartReader.GetString(0);
                    dDepartCombo.Items.Add(DepartNameFromtbl);
                }
                LoadDepartReader.Close();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            dBConn.Close();
        }