Force Requery

  • Thread starter Thread starter Chris Kennedy
  • Start date Start date
C

Chris Kennedy

I have a dropdownmenu which is databound to a table via a dataadapter and
dataset. A control on another part of the form updates the same table in the
database. On postback the dropdown does not show the new record. I have
tried the autopost back on true or false. I am assuming the dataset is
remaining disconnected. Is there an easy way to get the dataadapter to
requery itself.
 
Hi Chris,

Chris Kennedy said:
I have a dropdownmenu which is databound to a table via a dataadapter and
dataset.

Actually it is bound to dataset and not to adapter.

A control on another part of the form updates the same table in the
database. On postback the dropdown does not show the new record. I have
tried the autopost back on true or false. I am assuming the dataset is
remaining disconnected.

Dataset is always disconnected.

Is there an easy way to get the dataadapter to
requery itself.

Fill method? But it is you that have to invoke the method - it won't do it
automatically.
 
In my page load I am automatically filling the dataset from the dataadapter
the dataadapter. Is there a fill method for the data adapter as well?
 
Everytime the page loads I use this code. It doesn't refresh the
dropdownlist (autopostback on true and false). When I submit the form which
posts stuff to a database table etc the dataadapter doesn't update. I
thought by doing this I was invoking the fill method. Confused :)
What do I do to force the dataadapter to update on every page load as it
would in classic ADO.

Dim dsProducts As New Data.DataSet()
SqlDataAdapter1.Fill(dsProducts)
drpProducts.DataTextField = "CMSDESCRIPTION"
drpProducts.DataValueField = "CMSID"
drpProducts.DataSource = dsProducts
drpProducts.DataBind()
 
You are invoking fill each time. This gets called every single time
(Page.IsPostBack && !Page.IsPostBack ?)

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
Chris Kennedy said:
Everytime the page loads I use this code. It doesn't refresh the
dropdownlist (autopostback on true and false). When I submit the form which
posts stuff to a database table etc the dataadapter doesn't update. I
thought by doing this I was invoking the fill method. Confused :)
What do I do to force the dataadapter to update on every page load as it
would in classic ADO.

Dim dsProducts As New Data.DataSet()
SqlDataAdapter1.Fill(dsProducts)
drpProducts.DataTextField = "CMSDESCRIPTION"
drpProducts.DataValueField = "CMSID"
drpProducts.DataSource = dsProducts
drpProducts.DataBind()


William Ryan eMVP said:
If you have new data you are going to have to call Fill on the dataAdapter
again

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
Chris Kennedy said:
In my page load I am automatically filling the dataset from the dataadapter
the dataadapter. Is there a fill method for the data adapter as well?


"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
Hi Chris,

I have a dropdownmenu which is databound to a table via a dataadapter
and
dataset.

Actually it is bound to dataset and not to adapter.

A control on another part of the form updates the same table in the
database. On postback the dropdown does not show the new record. I have
tried the autopost back on true or false. I am assuming the
dataset
 
Why isn't the new data in the database showing up do I need to recreate the
dataadapter as well?

William Ryan eMVP said:
You are invoking fill each time. This gets called every single time
(Page.IsPostBack && !Page.IsPostBack ?)

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
Chris Kennedy said:
Everytime the page loads I use this code. It doesn't refresh the
dropdownlist (autopostback on true and false). When I submit the form which
posts stuff to a database table etc the dataadapter doesn't update. I
thought by doing this I was invoking the fill method. Confused :)
What do I do to force the dataadapter to update on every page load as it
would in classic ADO.

Dim dsProducts As New Data.DataSet()
SqlDataAdapter1.Fill(dsProducts)
drpProducts.DataTextField = "CMSDESCRIPTION"
drpProducts.DataValueField = "CMSID"
drpProducts.DataSource = dsProducts
drpProducts.DataBind()


William Ryan eMVP said:
If you have new data you are going to have to call Fill on the dataAdapter
again

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
In my page load I am automatically filling the dataset from the
dataadapter
the dataadapter. Is there a fill method for the data adapter as well?


"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
Hi Chris,

I have a dropdownmenu which is databound to a table via a dataadapter
and
dataset.

Actually it is bound to dataset and not to adapter.

A control on another part of the form updates the same table in the
database. On postback the dropdown does not show the new record. I
have
tried the autopost back on true or false. I am assuming the
dataset
is
remaining disconnected.

Dataset is always disconnected.

Is there an easy way to get the dataadapter to
requery itself.

Fill method? But it is you that have to invoke the method - it
won't
do
it
automatically.
 
Back
Top