Halaman

Sabtu, 15 Mei 2010

My list show only one record after doing edit-close form repeatedly

I was coding a form with a datagridview for single table. All Insert, Update, and Delete operations work well and satisfy me. But I saw a strange behaviour, when I did these:

1. Open the form, Edit some data, then click Save button..(data updated successfully!)
2. Close the form.
3. Do step 1-2 repeatedly.

After n times opening-editing-closing the form, the datagridview only show one record???
My list show only one record after doing edit-close form repeatedly.

public partial class frmCoa : mybasefrm.frmMainGrdView
{
private MySqlDataAdapter gda;
private DataTable gdt;
private DBOPS.SqlHelper;

private void frmCoa_Load(object sender, EventArgs e)
{
gHelper = new DBOPS.SqlHelper();
gda = gHelper.getDataAdapter("SELECT * FROM akun");
MySqlCommandBuilder gcmdBldr = new MySqlCommandBuilder(gda);
gdt = new DataTable();
gda.Fill(gdt);
bindSrc0.DataSource = gdt;
bindNav0.BindingSource = bindSrc0;
dgv.DataSource = bindSrc0;
...do binding
}

private void btnSave_Click(object sender, EventArgs e)
{
try
{
Validate();
bindSrc0.EndEdit();
gda.Update(gdt);
startingEdit(false);
base.buttonNormal();
}
catch (System.Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
return;
}
dgv.Enabled = true;
}
}


.

The form has a Query button, then without closing the application, I did some query to display all or some data, all query work as expected.

Don't know why this happened, and my guess is related to connection and data adapter (Fill method). I disable pooling connection in my connection string, and this seems quite resolve my problem. Any idea?

Tidak ada komentar:

Posting Komentar