I've been playing with using static properties using a simple example and i
see the potential for some site performance boosts. As i'm a little new to
the concepts i'd like to ask if what i'm about to propose is possible and if
so a good idea.
I have a few data readers for various reports that are sql intensive, but
small (about 20-30 rows).
can i create a static datareader or a static dataadapter as a property? so
that it can be run once and kept in memory as a read only item? The data
would need to be refreshed a few times during the day as information changes.
--
Share The Knowledge. I need all the help I can get and so do you! 5 1304
I wouldn't recommend it. If you hold a data reader and don't close it,
then the connection associated with it is held open. The thing with a data
reader as well is that it works in a forward-only, read-only manner.
Because of that, the connection staying open, and no way to reopen the data
reader after it is closed, you are better off creating a new data reader
(along with a new connection) to use every time you need it.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Yankee Imperialist Dog" <Ya******************@discussions.microsoft.com>
wrote in message news:CF**********************************@microsof t.com...
I've been playing with using static properties using a simple example and
i
see the potential for some site performance boosts. As i'm a little new to
the concepts i'd like to ask if what i'm about to propose is possible and
if
so a good idea.
I have a few data readers for various reports that are sql intensive, but
small (about 20-30 rows).
can i create a static datareader or a static dataadapter as a property? so
that it can be run once and kept in memory as a read only item? The data
would need to be refreshed a few times during the day as information
changes.
--
Share The Knowledge. I need all the help I can get and so do you!
thanks for responding,
My mistake reader was the wrong item to suggest better would be an adaptor
or a data table that can be bound on demand to a gridview for readonly data.
Do you think this would work? I'd even go for creating an object datasource
out of it if i can make it static.
Thank you!
--
Share The Knowledge. I need all the help I can get and so do you!
"Nicholas Paldino [.NET/C# MVP]" wrote:
I wouldn't recommend it. If you hold a data reader and don't close it,
then the connection associated with it is held open. The thing with a data
reader as well is that it works in a forward-only, read-only manner.
Because of that, the connection staying open, and no way to reopen the data
reader after it is closed, you are better off creating a new data reader
(along with a new connection) to use every time you need it.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Yankee Imperialist Dog" <Ya******************@discussions.microsoft.com>
wrote in message news:CF**********************************@microsof t.com...
I've been playing with using static properties using a simple example and
i
see the potential for some site performance boosts. As i'm a little new to
the concepts i'd like to ask if what i'm about to propose is possible and
if
so a good idea.
I have a few data readers for various reports that are sql intensive, but
small (about 20-30 rows).
can i create a static datareader or a static dataadapter as a property? so
that it can be run once and kept in memory as a read only item? The data
would need to be refreshed a few times during the day as information
changes.
--
Share The Knowledge. I need all the help I can get and so do you!
You could possibly store a SqlDataAdapter as a static instance, however,
if you are pounding on it from multiple threads, then you are going to have
to synchronize access, and you are probably going to lose any performance
benefit that you gain. Also, you would have to pass the connection to your
method which uses the data adapter, and set the connection on the commands
attached to it, as you can't leave those open and on the command.
All in all, you are better off creating the connection, creating your
adapters, using it, and then disposing of it properly.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Yankee Imperialist Dog" <Ya******************@discussions.microsoft.com>
wrote in message news:26**********************************@microsof t.com...
thanks for responding,
My mistake reader was the wrong item to suggest better would be an adaptor
or a data table that can be bound on demand to a gridview for readonly
data.
Do you think this would work? I'd even go for creating an object
datasource
out of it if i can make it static.
Thank you!
--
Share The Knowledge. I need all the help I can get and so do you!
"Nicholas Paldino [.NET/C# MVP]" wrote:
> I wouldn't recommend it. If you hold a data reader and don't close it, then the connection associated with it is held open. The thing with a data reader as well is that it works in a forward-only, read-only manner. Because of that, the connection staying open, and no way to reopen the data reader after it is closed, you are better off creating a new data reader (along with a new connection) to use every time you need it.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Yankee Imperialist Dog" <Ya******************@discussions.microsoft.com> wrote in message news:CF**********************************@microso ft.com...
I've been playing with using static properties using a simple example
and
i
see the potential for some site performance boosts. As i'm a little new
to
the concepts i'd like to ask if what i'm about to propose is possible
and
if
so a good idea.
I have a few data readers for various reports that are sql intensive,
but
small (about 20-30 rows).
can i create a static datareader or a static dataadapter as a property?
so
that it can be run once and kept in memory as a read only item? The
data
would need to be refreshed a few times during the day as information
changes.
--
Share The Knowledge. I need all the help I can get and so do you!
thank you,
Well, i had an idea, a good one but there are better ways to do this. I
really appreciate your advise and I'll follow it.
I do what i'm suggesting all the time in ColdFusion, only problem is it can
NOT be done with sp's must use ad hoc queries. Can you or anyone else
recomend a good way to cache a result set for the use i'm suggesting?
--
Share The Knowledge. I need all the help I can get and so do you!
"Nicholas Paldino [.NET/C# MVP]" wrote:
You could possibly store a SqlDataAdapter as a static instance, however,
if you are pounding on it from multiple threads, then you are going to have
to synchronize access, and you are probably going to lose any performance
benefit that you gain. Also, you would have to pass the connection to your
method which uses the data adapter, and set the connection on the commands
attached to it, as you can't leave those open and on the command.
All in all, you are better off creating the connection, creating your
adapters, using it, and then disposing of it properly.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Yankee Imperialist Dog" <Ya******************@discussions.microsoft.com>
wrote in message news:26**********************************@microsof t.com...
thanks for responding,
My mistake reader was the wrong item to suggest better would be an adaptor
or a data table that can be bound on demand to a gridview for readonly
data.
Do you think this would work? I'd even go for creating an object
datasource
out of it if i can make it static.
Thank you!
--
Share The Knowledge. I need all the help I can get and so do you!
"Nicholas Paldino [.NET/C# MVP]" wrote:
I wouldn't recommend it. If you hold a data reader and don't close
it,
then the connection associated with it is held open. The thing with a
data
reader as well is that it works in a forward-only, read-only manner.
Because of that, the connection staying open, and no way to reopen the
data
reader after it is closed, you are better off creating a new data reader
(along with a new connection) to use every time you need it.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Yankee Imperialist Dog" <Ya******************@discussions.microsoft.com>
wrote in message
news:CF**********************************@microsof t.com...
I've been playing with using static properties using a simple example
and
i
see the potential for some site performance boosts. As i'm a little new
to
the concepts i'd like to ask if what i'm about to propose is possible
and
if
so a good idea.
I have a few data readers for various reports that are sql intensive,
but
small (about 20-30 rows).
can i create a static datareader or a static dataadapter as a property?
so
that it can be run once and kept in memory as a read only item? The
data
would need to be refreshed a few times during the day as information
changes.
--
Share The Knowledge. I need all the help I can get and so do you!
Why not store the results in a DataSet/DataTable and then access that?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Yankee Imperialist Dog" <Ya******************@discussions.microsoft.com>
wrote in message news:B1**********************************@microsof t.com...
thank you,
Well, i had an idea, a good one but there are better ways to do this. I
really appreciate your advise and I'll follow it.
I do what i'm suggesting all the time in ColdFusion, only problem is it
can
NOT be done with sp's must use ad hoc queries. Can you or anyone else
recomend a good way to cache a result set for the use i'm suggesting?
--
Share The Knowledge. I need all the help I can get and so do you!
"Nicholas Paldino [.NET/C# MVP]" wrote:
> You could possibly store a SqlDataAdapter as a static instance, however, if you are pounding on it from multiple threads, then you are going to have to synchronize access, and you are probably going to lose any performance benefit that you gain. Also, you would have to pass the connection to your method which uses the data adapter, and set the connection on the commands attached to it, as you can't leave those open and on the command.
All in all, you are better off creating the connection, creating your adapters, using it, and then disposing of it properly.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com "Yankee Imperialist Dog" <Ya******************@discussions.microsoft.com> wrote in message news:26**********************************@microso ft.com...
thanks for responding,
My mistake reader was the wrong item to suggest better would be an
adaptor
or a data table that can be bound on demand to a gridview for readonly
data.
Do you think this would work? I'd even go for creating an object
datasource
out of it if i can make it static.
Thank you!
--
Share The Knowledge. I need all the help I can get and so do you!
"Nicholas Paldino [.NET/C# MVP]" wrote:
I wouldn't recommend it. If you hold a data reader and don't close it, then the connection associated with it is held open. The thing with a data reader as well is that it works in a forward-only, read-only manner. Because of that, the connection staying open, and no way to reopen the data reader after it is closed, you are better off creating a new data reader (along with a new connection) to use every time you need it.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Yankee Imperialist Dog" <Ya******************@discussions.microsoft.com > wrote in message news:CF**********************************@microso ft.com...
I've been playing with using static properties using a simple
example
and
i
see the potential for some site performance boosts. As i'm a little
new
to
the concepts i'd like to ask if what i'm about to propose is
possible
and
if
so a good idea.
I have a few data readers for various reports that are sql
intensive,
but
small (about 20-30 rows).
can i create a static datareader or a static dataadapter as a
property?
so
that it can be run once and kept in memory as a read only item? The
data
would need to be refreshed a few times during the day as information
changes.
--
Share The Knowledge. I need all the help I can get and so do you!
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Sergey Klementiev |
last post by:
Why it's impossible to have a static indexer in C#?
|
by: ~~~ .NET Ed ~~~ |
last post by:
Yes, I think so at least... In C# you *can* have static properties which are
quite useful when used properly. Now imagine the scenario where you need the
ability (sp?) to implement a variety of...
|
by: Wysiwyg |
last post by:
I'm new to c# programming and can't figure out how to avoid duplicating
common code in multiple classes when I'm restricted to using different
system base classes.. I'm using c# in asp.net to write...
|
by: Sahil Malik [MVP] |
last post by:
So here's a rather simple question.
Say in an ASP.NET application, I wish to share common constants as static
variables in global.asax (I know there's web.config bla bla .. but lets just
say I...
|
by: Mantorok |
last post by:
Hi
I have an ASP app which references a few static properties in some of the
classes. I understand that you should use Session variables, but is it
"possible" to have each session "not"...
|
by: JackRazz |
last post by:
Is it possible to create a static class in vb.net like c# does? I want the code to
create a single global instance of a class that is inherited from another class. I
could use a module, but I...
|
by: Kevin Prichard |
last post by:
Hi all,
I've recently been following the object-oriented techiques discussed
here and have been testing them for use in a web application. There is
problem that I'd like to discuss with you...
|
by: Mark P |
last post by:
Still being relatively new to C++ I like to go back to review and
rethink old designs to see where I could do things better. The issue
I'm currently pondering is static vs. dynamic polymorphism,...
|
by: Random |
last post by:
Here's a design question I'm curious to know if anyone here has wrestled
with before...
I'm writing my data access methods in classes in the App_Code directory. I
know that I can easily...
|
by: wagger |
last post by:
Hi!
I am creating a set of static classes, one class for each "case" I have. The class should do and perform certain things, and the different static classes are doing different things.
However,...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
| |