string constr = "Data Source=*****;Initial Catalog=*****;Integrated Security=True";
string str_select2 = "SELECT * FROM Departments";
string str_select = str_select2 ;
SqlConnection con = new SqlConnection(constr);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(str_select, con);
try
{
da.Fill(ds, "Departments");
DataTable datable = ds.Tables["Departments"];
comboBox1.DataSource = datable;
comboBox1.DisplayMember = "Department";
comboBox1.ValueMember = "Department_No";
}
catch (Exception ex)
{
}
2010年2月10日 星期三
C# comboBox顯示資料庫列 可對應值
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言