473,472 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

best way to refresh a dataset.

I have a function that call a stored procedure which performs an
insert command. now i want to refresh the dataset so that the newly
inserted data will be available to my datagrid

I have tried to call

DsStudentCourse1.Tables("SchYrSemCourseJoin").Clea r()
SqlDataAdapter3.Fill(DsStudentCourse1)

However, the fill method causes a lot of time to process.

anyone know what is the best way to fill/refresh the dataset again so
that the newly inserted records will be available to my datagrid?

thanks in advance.
Nov 21 '05 #1
10 30593
Hi,

if the data to be loaded to the dataset is relatively large, the best way of
calling the fill method is via a callback method asynchronously which will
create a separate thread to run in parallel with the main thread. When the
new thread is finished the callback mechanism will let the main thread know
that the operation is finished, so that you can show the results. See more
in this recent MSDN magazine article: -
http://msdn.microsoft.com/msdnmag/is...asicInstincts/

Regards
Joyjit

"jaYPee" <hi******@yahoo.com> wrote in message
news:0k********************************@4ax.com...
I have a function that call a stored procedure which performs an
insert command. now i want to refresh the dataset so that the newly
inserted data will be available to my datagrid

I have tried to call

DsStudentCourse1.Tables("SchYrSemCourseJoin").Clea r()
SqlDataAdapter3.Fill(DsStudentCourse1)

However, the fill method causes a lot of time to process.

anyone know what is the best way to fill/refresh the dataset again so
that the newly inserted records will be available to my datagrid?

thanks in advance.

Nov 21 '05 #2
Joyjit,

I have readed this often. Can you tell me what is the benefit from this,
with this sample you now have to monitor that the work is done.

The user is only interested that his screen is not freezed but while doing
this can see something.

It looks for me a nice method for the programmer who can be very proud on
it, however for the enduser it gives in my opinion not any benefit except
that he can close his application while the datagrid is updating.

Which means that when there are errors those are never catched and your
database has errors somewhere in the middle. (Which can be catched in the
thread of course as well however makes it only more difficult, because of
the communication with the UI )

I think that when you want this kind of things using the dataadapter events
are a much better way to do this.

http://msdn.microsoft.com/library/de...nts.aspHowever just my thought, and when I see something wrong tell me?Coir"Joyjit Mukherjee" <jo**************@hotmail.com>> Hi,>> if the data to be loaded to the dataset is relatively large, the best wayof> calling the fill method is via a callback method asynchronously which will> create a separate thread to run in parallel with the main thread. When the> new thread is finished the callback mechanism will let the main threadknow> that the operation is finished, so that you can show the results. See more> in this recent MSDN magazine article: -> http://msdn.microsoft.com/msdnmag/issues/04/01/BasicInstincts/>> Regards> Joyjit>> "jaYPee" <hi******@yahoo.com> wrote in message> news:0k********************************@4ax.com... >> I have a function that call a stored procedure which performs an>> insert command. now i want to refresh the dataset so that the newly>> inserted data will be available to my datagrid>>>> I have tried to call>>>> DsStudentCourse1.Tables("SchYrSemCourseJoin").Clea r()>> SqlDataAdapter3.Fill(DsStudentCourse1)>>>> However, the fill method causes a lot of time to process.>>>> anyone know what is the best way to fill/refresh the dataset again so>> that the newly inserted records will be available to my datagrid?>>>> thanks in advance.>>

Nov 21 '05 #3
Something went wrong it seems.

http://msdn.microsoft.com/library/de...iderEvents.asp

However just my thoughts,

Cor
Nov 21 '05 #4
Thanks a lot. But I think this is not what I am looking for.

I made a lot of research regarding this problem and I saw so many
threads that has the same problem. I think this is cause by a
disconnected dataset. If I will use the data reader the disadvantages
is that it is a forward only. Which means that I can't update it.

I am now looking for an alternative on how can I insert the new
records to my table called "schyrsemcoursejoin" based on the other
table called "coursetemplate".

Because if I use stored procedure I have to fill the SqlDataAdapter
again and this takes a lot of time to process.

On Thu, 18 Nov 2004 09:27:12 +0100, "Cor Ligthert"
<no************@planet.nl> wrote:
Something went wrong it seems.

http://msdn.microsoft.com/library/de...iderEvents.asp

However just my thoughts,

Cor


Nov 21 '05 #5
> I have a function that call a stored procedure which performs an
insert command. now i want to refresh the dataset so that the newly
inserted data will be available to my datagrid
I have tried to call
DsStudentCourse1.Tables("SchYrSemCourseJoin").Clea r()
SqlDataAdapter3.Fill(DsStudentCourse1)
However, the fill method causes a lot of time to process.
anyone know what is the best way to fill/refresh the dataset again so
that the newly inserted records will be available to my datagrid?


I use the SqlDataAdapter a lot. In my experience the actual .Fill is very
cheap. Most of the time is used up by sqlserver executing the sproc. At
least, that's my experience. I do the .Fill directly on the datatable
though, not on the dataset, maybe that saves some time (seems unlikely
though).

Something like

dim dt as DataTable = ctype(myGrid.DataSource, DataTable)
dt.Clear
mySqlAdapter.Fill(dt)

You should check how much time it takes for your sproc to execute. That's
where I solve most performance issues -> TSQL optimization. Allthough I have
to say I never had to deal with resultsets >> 1000 rows, so maybe that's why
I never had any problems with the SqlDataAdapter.
Nov 21 '05 #6
Hi,

In my part it's not the stored procedure that executes a lot of time.
It is the fill method of an sqldataadapter that takes longer time to
execute.

May be that's why you don't have a problem refreshing the dataset
again because you are not dealing with more than 1000 rows. My table
as of now contains more than 50,000 records. So as what I have learn
(correct me if i'm wrong) you need to pull out all the data into the
dataset. One more thing is that this table is related from the other
table (a.k.a. parent/child).

On Thu, 18 Nov 2004 16:03:48 +0100, "Jonas Pohlandt"
<j.******************@dbit-systems.de> wrote:
I have a function that call a stored procedure which performs an
insert command. now i want to refresh the dataset so that the newly
inserted data will be available to my datagrid
I have tried to call
DsStudentCourse1.Tables("SchYrSemCourseJoin").Clea r()
SqlDataAdapter3.Fill(DsStudentCourse1)
However, the fill method causes a lot of time to process.
anyone know what is the best way to fill/refresh the dataset again so
that the newly inserted records will be available to my datagrid?


I use the SqlDataAdapter a lot. In my experience the actual .Fill is very
cheap. Most of the time is used up by sqlserver executing the sproc. At
least, that's my experience. I do the .Fill directly on the datatable
though, not on the dataset, maybe that saves some time (seems unlikely
though).

Something like

dim dt as DataTable = ctype(myGrid.DataSource, DataTable)
dt.Clear
mySqlAdapter.Fill(dt)

You should check how much time it takes for your sproc to execute. That's
where I solve most performance issues -> TSQL optimization. Allthough I have
to say I never had to deal with resultsets >> 1000 rows, so maybe that's why
I never had any problems with the SqlDataAdapter.


Nov 21 '05 #7
Hi Cor,

the main benefit is improved user experience. An end user feels more
comfortable to see a message like "Please wait while data is been loaded"
while the background thread populates the dataset than seeing the screen
freezing during the activity. Also, you can proceed with doing something
else as the main thread is not blocked.

Yes, you are right, database & data adapter errors are not caught directly
because you have very little control over async operation. Still you can set
some properties to get those later for proceedings.

Basically, the implementation models for both the async callbacks & events
are same, they use delegates. But you have two different approaches to go as
per your requirements.

Thanks
Joyjit

"Cor Ligthert" <no************@planet.nl> wrote in message
news:Oj**************@TK2MSFTNGP09.phx.gbl...
Joyjit,

I have readed this often. Can you tell me what is the benefit from this,
with this sample you now have to monitor that the work is done.

The user is only interested that his screen is not freezed but while doing
this can see something.

It looks for me a nice method for the programmer who can be very proud on
it, however for the enduser it gives in my opinion not any benefit except
that he can close his application while the datagrid is updating.

Which means that when there are errors those are never catched and your
database has errors somewhere in the middle. (Which can be catched in the
thread of course as well however makes it only more difficult, because of
the communication with the UI )

I think that when you want this kind of things using the dataadapter events are a much better way to do this.

http://msdn.microsoft.com/library/de...nts.aspHowever
just my thought, and when I see something wrong tell me?Coir"Joyjit
Mukherjee" <jo**************@hotmail.com>> Hi,>> if the data to be loaded to
the dataset is relatively large, the best wayof> calling the fill method is
via a callback method asynchronously which will> create a separate thread to
run in parallel with the main thread. When the> new thread is finished the
callback mechanism will let the main threadknow> that the operation is
finished, so that you can show the results. See more> in this recent MSDN
magazine article: ->
http://msdn.microsoft.com/msdnmag/issues/04/01/BasicInstincts/>> Regards>
Joyjit>> "jaYPee" <hi******@yahoo.com> wrote in message>
news:0k********************************@4ax.com... >> I have a function that
call a stored procedure which performs an>> insert command. now i want to
refresh the dataset so that the newly>> inserted data will be available to
my datagrid>>>> I have tried to call>>>>
DsStudentCourse1.Tables("SchYrSemCourseJoin").Clea r()>>
SqlDataAdapter3.Fill(DsStudentCourse1)>>>> However, the fill method causes a
lot of time to process.>>>> anyone know what is the best way to fill/refresh
the dataset again so>> that the newly inserted records will be available to
my datagrid?>>>> thanks in advance.>>

Nov 21 '05 #8
Joyjit,

I am not agains using multithreading, in the oposite I use it, however
sometimes I get in this newsgroups the idea that it is overdone. The case of
loading or updating a dataset is such a situation. The calling process is
completly dependable of the result of that procedure and nothing can be done
between. When that is an update even not a close what becomes possible when
the UI is not waiting on the result, however can be closed in between.

However just my thought,

Cor

"Joyjit Mukherjee" <jo**************@hotmail.com>

Hi Cor,

the main benefit is improved user experience. An end user feels more
comfortable to see a message like "Please wait while data is been loaded"
while the background thread populates the dataset than seeing the screen
freezing during the activity. Also, you can proceed with doing something
else as the main thread is not blocked.

Yes, you are right, database & data adapter errors are not caught directly
because you have very little control over async operation. Still you can
set
some properties to get those later for proceedings.

Basically, the implementation models for both the async callbacks & events
are same, they use delegates. But you have two different approaches to go
as
per your requirements.

Thanks
Joyjit

"Cor Ligthert" <no************@planet.nl> wrote in message
news:Oj**************@TK2MSFTNGP09.phx.gbl...
Joyjit,

I have readed this often. Can you tell me what is the benefit from this,
with this sample you now have to monitor that the work is done.

The user is only interested that his screen is not freezed but while
doing
this can see something.

It looks for me a nice method for the programmer who can be very proud on
it, however for the enduser it gives in my opinion not any benefit except
that he can close his application while the datagrid is updating.

Which means that when there are errors those are never catched and your
database has errors somewhere in the middle. (Which can be catched in the
thread of course as well however makes it only more difficult, because of
the communication with the UI )

I think that when you want this kind of things using the dataadapter

events
are a much better way to do this.

http://msdn.microsoft.com/library/de...nts.aspHowever
just my thought, and when I see something wrong tell me?Coir"Joyjit
Mukherjee" <jo**************@hotmail.com>> Hi,>> if the data to be loaded
to
the dataset is relatively large, the best wayof> calling the fill method
is
via a callback method asynchronously which will> create a separate thread
to
run in parallel with the main thread. When the> new thread is finished the
callback mechanism will let the main threadknow> that the operation is
finished, so that you can show the results. See more> in this recent MSDN
magazine article: ->
http://msdn.microsoft.com/msdnmag/issues/04/01/BasicInstincts/>> Regards>
Joyjit>> "jaYPee" <hi******@yahoo.com> wrote in message>
news:0k********************************@4ax.com... >> I have a function
that
call a stored procedure which performs an>> insert command. now i want to
refresh the dataset so that the newly>> inserted data will be available to
my datagrid>>>> I have tried to call>>>>
DsStudentCourse1.Tables("SchYrSemCourseJoin").Clea r()>>
SqlDataAdapter3.Fill(DsStudentCourse1)>>>> However, the fill method causes
a
lot of time to process.>>>> anyone know what is the best way to
fill/refresh
the dataset again so>> that the newly inserted records will be available
to
my datagrid?>>>> thanks in advance.>>


Nov 21 '05 #9
jaYpee,

When it is not for one time loading on a PDA or something, it is not a good
approach to use such huge datasets.

You would better cut your dataset in usable formats, where you can think on
about 200 datarows as goal.

The loading of that huge dataset is in a multiuser environment probably only
the first problem you will be confrontated with. There will be much more
going on in my opinion.

Just my thought,

Cor

"jaYPee" <hi******@yahoo.com>
Hi,

In my part it's not the stored procedure that executes a lot of time.
It is the fill method of an sqldataadapter that takes longer time to
execute.

May be that's why you don't have a problem refreshing the dataset
again because you are not dealing with more than 1000 rows. My table
as of now contains more than 50,000 records. So as what I have learn
(correct me if i'm wrong) you need to pull out all the data into the
dataset. One more thing is that this table is related from the other
table (a.k.a. parent/child).

On Thu, 18 Nov 2004 16:03:48 +0100, "Jonas Pohlandt"
<j.******************@dbit-systems.de> wrote:
I have a function that call a stored procedure which performs an
insert command. now i want to refresh the dataset so that the newly
inserted data will be available to my datagrid
I have tried to call
DsStudentCourse1.Tables("SchYrSemCourseJoin").Clea r()
SqlDataAdapter3.Fill(DsStudentCourse1)
However, the fill method causes a lot of time to process.
anyone know what is the best way to fill/refresh the dataset again so
that the newly inserted records will be available to my datagrid?


I use the SqlDataAdapter a lot. In my experience the actual .Fill is very
cheap. Most of the time is used up by sqlserver executing the sproc. At
least, that's my experience. I do the .Fill directly on the datatable
though, not on the dataset, maybe that saves some time (seems unlikely
though).

Something like

dim dt as DataTable = ctype(myGrid.DataSource, DataTable)
dt.Clear
mySqlAdapter.Fill(dt)

You should check how much time it takes for your sproc to execute. That's
where I solve most performance issues -> TSQL optimization. Allthough I
have
to say I never had to deal with resultsets >> 1000 rows, so maybe that's
why
I never had any problems with the SqlDataAdapter.

Nov 21 '05 #10
> May be that's why you don't have a problem refreshing the dataset
again because you are not dealing with more than 1000 rows. My table
as of now contains more than 50,000 records. So as what I have learn
(correct me if i'm wrong) you need to pull out all the data into the
dataset. One more thing is that this table is related from the other
table (a.k.a. parent/child).


What do you mean by "you need to pull out all the data into the dataset"?
If you want to display 50k rows in your grid, then yes, you'd have to
populate the dataset with 50k rows. I just wonder, why would you like to
show 50k results? I think that is hardly usable. On the other side, I don't
know what you're doing in your app. If you want only want filtered results
to be shown in your grid, filter in the stored procedure and thereby reduce
the amount of data you have to populate your dataset with.
Nov 21 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: serge calderara | last post by:
Dear all, I have an application which is collecting dynamic incoming data and store them in a list. I need to dispaly this incoming list with 2 important recommandation : 1- if the incoming...
0
by: Carl | last post by:
Hi, I am trying to figure out the best approach for this simple scenario. I have one C# Windows application Form that consumes few web services for all data related function. In this form...
4
by: Alex Bibiano | last post by:
I have a typed dataset in my WinForm and a textbox with databinding to the dataset (all without code). Now, in a button event, I assign a new dataset (retrieved from a function) to the dataset a...
1
by: Romao | last post by:
Hi, None of the C#/ADO documentation I was able to read refers what are the best practices/implementations for this "kind of" problem, I would like to get help/opinions please, let me explain...
7
by: Juan Romero | last post by:
Hey guys, please HELP I am going nuts with the datagrid control. I cannot get the damn control to refresh. I am using soap to get information from a web service. I have an XML writer output...
12
by: Aaron Smith | last post by:
What is the best way to handle data in a multiple user environment? We have forms that will allow users to add edit and delete data from a table on SQL server. The data could be edited on multiple...
0
by: thomasp | last post by:
This is a two part question, 1) The code below should display a form with a datagridview and a few command buttons. This form should allow the user to make change to the records displayed in...
5
by: Rob | last post by:
I have a form where the user may see a matrix of data in a grid (populated via a dataset). If the user wishes to add a new row of data, they click a button and a new form opens where the user may...
6
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi - I'm having trouble refreshing a datagrid control bound to a dataset that was created from the New Data Source wizard. What is the code required to refresh the datagrid with data from the...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.