2017-02-22 102 views

回答

1

您希望從數據庫中獲得?然後你可以嘗試這樣的事情。

string Sql = "select brand from [Car]"; 
     SqlConnection conn = new SqlConnection(@"path_to_db"); 
     conn.Open(); 
     SqlCommand cmd = new SqlCommand(Sql, conn); 
     SqlDataReader DR = cmd.ExecuteReader(); 

     while (DR.Read()) 
     { 
      Invoke(new Action(() => ComboBox1.Items.Add(DR[0]))); 
     }