Page 1 of 1

Refresh existing DataTable / DataSet

Posted: Tue 09 Aug 2016 15:58
by chris901
Hello,

when my application starts I fill a PgSqlDataTable with some information from the database.

Then i navigate throught each record.

How can I refresh a single record at a later point?

Currently i do it like this:

Code: Select all

	
private void button1_Click_1(object sender, EventArgs e)
{
    var oldpos = dataLink1.Position;
		
    ds_actors.Reset();
    ds_actors.Fill();

    dataLink1.Position = oldpos;
}
I add an extra DataLink control to the form so the cursor is at the correct position after refreshing.

This also refreshes the whole dataset and not only the current row.

I only need to refresh the current row with live data from the database.

I read that you implemented such a functionality here:
viewtopic.php?t=9769

I also read this thread about QuickRefresh and Refresh:
viewtopic.php?t=23541

However this relates to Delphi. Is there a similiar functionality for dotConnect?

Can you please show me an example on how to update the current row only?


Thanks.

Re: Refresh existing DataTable / DataSet

Posted: Fri 12 Aug 2016 15:03
by Pinturiccio
Try using the following code:

Code: Select all

private void button1_Click(object sender, EventArgs e)
{
	dataLink1.CurrentRow.Refresh();
}

Re: Refresh existing DataTable / DataSet

Posted: Sun 14 Aug 2016 05:45
by chris901
That works, thanks.

Re: Refresh existing DataTable / DataSet

Posted: Wed 17 Aug 2016 10:49
by chris901
Hi,

just a quick follow-up question:

I noticed that i can also call

Code: Select all

this.dataAdapter.Fill(this);
inside the PgSqlDataTable to get updated data from the database.

Is this method valid or are there any side effects by using this way of refreshing the PgSqlDataTable.

Thanks.

Re: Refresh existing DataTable / DataSet

Posted: Fri 19 Aug 2016 15:37
by Pinturiccio
If you use this code in your own class derived from the PgSqlDataTable class, this code should successfully update all the data in the table, provided that SelectCommand is initialized.