hi all
in form1 I place 3 button and 1 datagridview ,btn refresh,btnload , btnnew and Datagridview dgv1
- I change the value of a cells in datagridview (right after Form1 is loaded),and then click btnrefresh
- I click btnnew to clear the dgv1
- I click btnload to re fill dgv1 with data from Database TblProduct.
why my dgv1 is empty .I think there must be something inside tblProduct to be
shown in dgv1,but nothing appear.Any body can teach me why ?
thank s
denny
code :
private void Form1_Load(object sender, EventArgs e)
{
string server = "localhost";
string dbname = "mydatabase";
string uid = "root";
string password = "rootpassword";
string connectionString = "SERVER=" + server + ";" + "DATABASE=" +
dbname + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
conn = new MySqlConnection(connectionString);
da = new MySqlDataAdapter("select * from Tblproduct", conn);
cbl = new MySqlCommandBuilder(da);
ds = new DataSet();
da.Fill(ds);
dgv1.DataSource = ds.Tables[0];
}
private void btnrefresh_Click(object sender, EventArgs e)
{
//now u can save changes to back end with
da.Update(ds);
}
private void btnnew_Click(object sender, EventArgs e)
{
dgv1.DataSource = null;
dgv1.DataMember = null;
}