namespace MovieProject { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void AutoradioButton1_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection("Server=CHRIS-PC\\SQLEXPRESS;Database=MovieDesc;" +"Integrated Security=True"); SqlCommand scmd = new SqlCommand("SELECT * FROM MovieType", conn); DataSet sds = new DataSet(); conn.Open(); SqlDataAdapter sadptr = new SqlDataAdapter(scmd); sadptr.Fill(sds, "MovieType"); if (sds.Tables["MovieType"].Rows.Count == 0) { MessageBox.Show("There are no DB."); } else { this.listBox1.DataSource = sds.Tables["MovieType"]; this.listBox1.DisplayMember = "Description"; } checkedListBox1.DataSource = sds.Tables["MovieType"]; checkedListBox1.DisplayMember = "Rating"; dataGridView1.DataSource = sds.Tables[0]; } } }
DataTable dt1 = sds.Tables[0]; dt1.Columns.Remove(dt1.Columns[0]); dt1.AcceptChanges(); dataGridView1.DataSource = dt1;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)