private void Form1_Load(object sender, EventArgs e)
{
using (SqlConnection sc
= new SqlConnection
()) {
sc.ConnectionString = @"Data Source=DANIELSQLEXPRESS;Initial Catalog=CloudNews;Integrated Security=True";
sc.Open();
const string cmd = "SELECT [name],[PartitionKey] From tableChannel";
using (SqlDataAdapter sda
= new SqlDataAdapter
(cmd, sc
)) {
DataTable dt
= new DataTable
(); sda.Fill(dt);
comboBox1.ValueMember = "name";
comboBox1.DisplayMember = "PartitionKey";
comboBox1.DataSource = dt;
}
}
}