Menampilkan data dari database MySQL ke datagridview dapat dengan script berikut :
conn.Open();
MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter("select * from `m-user`;", conn);
DataSet DS = new DataSet();
mySqlDataAdapter.Fill(DS);
dataGridView1.DataSource = DS.Tables[0];
dataGridView1.Columns[0].HeaderText = "ID";
dataGridView1.Columns[0].ReadOnly = true;
dataGridView1.Columns[0].Visible = false;
dataGridView1.Columns[1].HeaderText = "USERNAME";
dataGridView1.Columns[2].HeaderText = "PASSWORD";
conn.Close();
SELAMAT MENCOBA
No comments:
Post a Comment