Пример #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            cn = new OleDbConnection();
            cn.ConnectionString = "Provider=Microsoft.jet.oledb.4.0;Data Source=\\\\Juriel\\Data$\\OKT08.mdb;jet oledb:database password=ocomokt2008";
            try
            {
                cn.Open();
                cmd             = cn.CreateCommand();
                cmd.Connection  = cn;
                cmd.CommandText = "select p_num,p_name from ren_per_info order by p_name";
                cbNames.Items.Clear();
                dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    co       = new cbojbect();
                    co.Text  = dr.GetString(dr.GetOrdinal("p_name"));
                    co.Value = Int32.Parse((string)dr.GetValue(dr.GetOrdinal("p_num")));
                    cbNames.Items.Add("");
                    cbNames.Items[cbNames.Items.Count - 1] = (iproject.cbojbect)co;
                }
                dr.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
 private void cbNames_SelectedIndexChanged(object sender, EventArgs e)
 {
     co  = (iproject.cbojbect)cbNames.SelectedItem;
     uid = (int)co.Value;
     filllist();
 }