Code
1public void InsertComShopID(ComboBox cb)
2 {
3 cb.Items.Clear();//清空ComBox
4 SqlCommand cmd = new SqlCommand("select name from shop",DB.Getcon());//构造连接字符串并切打开数据库连接
5 SqlDataReader sdr =cmd.ExecuteReader();
6 while (sdr.Read())
7 {
8 cb.Items.Add(sdr[0].ToString());//循环读取数据
9 }//end block while
10
11 sdr.Close();// 关闭数据集
12 DB.GetColse();//关闭数据库连接
13 }
14
1public void InsertComShopID(ComboBox cb)
2 {
3 cb.Items.Clear();//清空ComBox
4 SqlCommand cmd = new SqlCommand("select name from shop",DB.Getcon());//构造连接字符串并切打开数据库连接
5 SqlDataReader sdr =cmd.ExecuteReader();
6 while (sdr.Read())
7 {
8 cb.Items.Add(sdr[0].ToString());//循环读取数据
9 }//end block while
10
11 sdr.Close();// 关闭数据集
12 DB.GetColse();//关闭数据库连接
13 }
14
或者
Code
1string ConnectionString = "Data Source=dzjc_2005;user=kk;password=kk;";//写连接串
2 OracleConnection conn = new OracleConnection(ConnectionString);//创建一个新连接
3
4 conn.Open();
5 OracleCommand cmd = conn.CreateCommand();
6 cmd.CommandText = "SELECT rname,did,rchannel FROM nwvideo.n_road ";//在这儿写sql语句
7 OracleDataReader dr = cmd.ExecuteReader();//创建一个OracleDateReader对象
8
9if (dr.HasRows)
10 {
11 cmbChannelSelect.Items.Clear();//清空ComBox
12 while (dr.Read())
13 {
14 cmbChannelSelect.Items.Add(dr[2].ToString());//循环读区数据
15
16 }
17 }
18
1string ConnectionString = "Data Source=dzjc_2005;user=kk;password=kk;";//写连接串
2 OracleConnection conn = new OracleConnection(ConnectionString);//创建一个新连接
3
4 conn.Open();
5 OracleCommand cmd = conn.CreateCommand();
6 cmd.CommandText = "SELECT rname,did,rchannel FROM nwvideo.n_road ";//在这儿写sql语句
7 OracleDataReader dr = cmd.ExecuteReader();//创建一个OracleDateReader对象
8
9if (dr.HasRows)
10 {
11 cmbChannelSelect.Items.Clear();//清空ComBox
12 while (dr.Read())
13 {
14 cmbChannelSelect.Items.Add(dr[2].ToString());//循环读区数据
15
16 }
17 }
18