从数据库中将信息绑定到DropDownList控件中
必须引用using System.Data.SqlClient
SqlConnection con = new SqlConnection("server=.;database=oa;user id=sa;pwd=;");
SqlCommand cmd = new SqlCommand("select * from OA_CRM_DWXZZD",con );
con.Open();
DropDownList1.DataSource = cmd.ExecuteReader();
DropDownList1.DataTextField = "MC";
DropDownList1.DataBind();
con.Close();
SqlConnection con = new SqlConnection("server=.;database=oa;user id=sa;pwd=;");
SqlCommand cmd = new SqlCommand("select * from OA_CRM_DWXZZD",con );
con.Open();
DropDownList1.DataSource = cmd.ExecuteReader();
DropDownList1.DataTextField = "MC";
DropDownList1.DataBind();
con.Close();