Refresh existing DataTable / DataSet

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
chris901
Posts: 64
Joined: Wed 20 Jul 2016 04:21

Refresh existing DataTable / DataSet

Post by chris901 » Tue 09 Aug 2016 15:58

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.

Pinturiccio
Devart Team
Posts: 2192
Joined: Wed 02 Nov 2011 09:44

Re: Refresh existing DataTable / DataSet

Post by Pinturiccio » Fri 12 Aug 2016 15:03

Try using the following code:

Code: Select all

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

chris901
Posts: 64
Joined: Wed 20 Jul 2016 04:21

Re: Refresh existing DataTable / DataSet

Post by chris901 » Sun 14 Aug 2016 05:45

That works, thanks.

chris901
Posts: 64
Joined: Wed 20 Jul 2016 04:21

Re: Refresh existing DataTable / DataSet

Post by chris901 » Wed 17 Aug 2016 10:49

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.

Pinturiccio
Devart Team
Posts: 2192
Joined: Wed 02 Nov 2011 09:44

Re: Refresh existing DataTable / DataSet

Post by Pinturiccio » Fri 19 Aug 2016 15:37

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.

Post Reply