473,395 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Caching

Hi, everyone.

Can someone direct me to the "how-to" on cachine data from a sql to a
datagrid?

Thanks
Jul 3 '06 #1
5 1420
Hi,

What you mean with caching data?

Are you refering to a dataset?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Antonio" <in**@awfulcards.comwrote in message
news:eN**************@TK2MSFTNGP02.phx.gbl...
Hi, everyone.

Can someone direct me to the "how-to" on cachine data from a sql to a
datagrid?

Thanks

Jul 3 '06 #2
Yes, Ignacio. This is what I have in the bindGrid method. See arrows. Is
it enough?

private void bindGrid()
{
SqlConnection conn = new SqlConnection
(ConfigurationSettings.AppSettings["SqlConnectionString"]);

conn.Open();

SqlCommand dataCommand = new SqlCommand();
dataCommand.Connection = conn;
dataCommand.CommandText = "SELECT GEM.customers.name AS [Institution
Name], "
+ "GEM.customers.CustomerSince AS [Customer Since], "
+ "GEM.contacts.name_first AS [First Name], "
+ "GEM.contacts.name_last AS [Last Name], "
+ "GEM.contacts.title AS [Contact Title], "
+ "GEM.customers.address_1 AS Address, "
+ "GEM.customers.city AS City, "
+ "GEM.customers.state AS State, "
+ "GEM.customers.province AS Province, "
+ "GEM.customers.zip_code AS [Zip Code], "
+ "GEM.customers.postal_code AS [Postal Code], "
+ "GEM.customers.country AS Country, "
+ "GEM.customers.phone AS Phone, "
+ "GEM.contacts.email AS [E-Mail Address], "
+ "GEM.customers.cust_id "
+ "FROM GEM.customers INNER JOIN GEM.config_usernames ON "
+ "GEM.customers.cust_id = GEM.config_usernames.cust_id INNER JOIN "
+ "GEM.contacts ON GEM.config_usernames.contact_id =
GEM.contacts.contact_id ORDER BY GEM.customers.name";

SqlDataAdapter adapter = new SqlDataAdapter(dataCommand);
DataSet ds = new DataSet();
adapter.Fill(ds);
Cache["CustomerData"] = ds; <-----------------------------------------
dgCustInfo.DataSource = ds;
ds = (DataSet)Cache["CustomerData"]; <------------------------------
dgCustInfo.DataBind();
conn.Close();
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.uswrote
in message news:ub**************@TK2MSFTNGP03.phx.gbl...
Hi,

What you mean with caching data?

Are you refering to a dataset?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Antonio" <in**@awfulcards.comwrote in message
news:eN**************@TK2MSFTNGP02.phx.gbl...
>Hi, everyone.

Can someone direct me to the "how-to" on cachine data from a sql to a
datagrid?

Thanks


Jul 3 '06 #3
Yes, that is how you store and retrieve values in the cache. Your code
doesn't do anything useful, though.

Antonio wrote:
Yes, Ignacio. This is what I have in the bindGrid method. See arrows. Is
it enough?

private void bindGrid()
{
SqlConnection conn = new SqlConnection
(ConfigurationSettings.AppSettings["SqlConnectionString"]);

conn.Open();

SqlCommand dataCommand = new SqlCommand();
dataCommand.Connection = conn;
dataCommand.CommandText = "SELECT GEM.customers.name AS [Institution
Name], "
+ "GEM.customers.CustomerSince AS [Customer Since], "
+ "GEM.contacts.name_first AS [First Name], "
+ "GEM.contacts.name_last AS [Last Name], "
+ "GEM.contacts.title AS [Contact Title], "
+ "GEM.customers.address_1 AS Address, "
+ "GEM.customers.city AS City, "
+ "GEM.customers.state AS State, "
+ "GEM.customers.province AS Province, "
+ "GEM.customers.zip_code AS [Zip Code], "
+ "GEM.customers.postal_code AS [Postal Code], "
+ "GEM.customers.country AS Country, "
+ "GEM.customers.phone AS Phone, "
+ "GEM.contacts.email AS [E-Mail Address], "
+ "GEM.customers.cust_id "
+ "FROM GEM.customers INNER JOIN GEM.config_usernames ON "
+ "GEM.customers.cust_id = GEM.config_usernames.cust_id INNER JOIN "
+ "GEM.contacts ON GEM.config_usernames.contact_id =
GEM.contacts.contact_id ORDER BY GEM.customers.name";

SqlDataAdapter adapter = new SqlDataAdapter(dataCommand);
DataSet ds = new DataSet();
adapter.Fill(ds);
Cache["CustomerData"] = ds; <-----------------------------------------
dgCustInfo.DataSource = ds;
ds = (DataSet)Cache["CustomerData"]; <------------------------------
dgCustInfo.DataBind();
conn.Close();
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.uswrote
in message news:ub**************@TK2MSFTNGP03.phx.gbl...
>Hi,

What you mean with caching data?

Are you refering to a dataset?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Antonio" <in**@awfulcards.comwrote in message
news:eN**************@TK2MSFTNGP02.phx.gbl...
>>Hi, everyone.

Can someone direct me to the "how-to" on cachine data from a sql to a
datagrid?

Thanks

Jul 3 '06 #4
With the method below, ain't I accessing the database directly, everytime
the data is requested? What's the solution, if I don't want to query the
database directly everytime?

"Göran Andersson" <gu***@guffa.comwrote in message
news:OO**************@TK2MSFTNGP05.phx.gbl...
Yes, that is how you store and retrieve values in the cache. Your code
doesn't do anything useful, though.

Antonio wrote:
>Yes, Ignacio. This is what I have in the bindGrid method. See arrows.
Is it enough?

private void bindGrid()
{
SqlConnection conn = new SqlConnection
(ConfigurationSettings.AppSettings["SqlConnectionString"]);

conn.Open();

SqlCommand dataCommand = new SqlCommand();
dataCommand.Connection = conn;
dataCommand.CommandText = "SELECT GEM.customers.name AS [Institution
Name], "
+ "GEM.customers.CustomerSince AS [Customer Since], "
+ "GEM.contacts.name_first AS [First Name], "
+ "GEM.contacts.name_last AS [Last Name], "
+ "GEM.contacts.title AS [Contact Title], "
+ "GEM.customers.address_1 AS Address, "
+ "GEM.customers.city AS City, "
+ "GEM.customers.state AS State, "
+ "GEM.customers.province AS Province, "
+ "GEM.customers.zip_code AS [Zip Code], "
+ "GEM.customers.postal_code AS [Postal Code], "
+ "GEM.customers.country AS Country, "
+ "GEM.customers.phone AS Phone, "
+ "GEM.contacts.email AS [E-Mail Address], "
+ "GEM.customers.cust_id "
+ "FROM GEM.customers INNER JOIN GEM.config_usernames ON "
+ "GEM.customers.cust_id = GEM.config_usernames.cust_id INNER JOIN "
+ "GEM.contacts ON GEM.config_usernames.contact_id =
GEM.contacts.contact_id ORDER BY GEM.customers.name";

SqlDataAdapter adapter = new SqlDataAdapter(dataCommand);
DataSet ds = new DataSet();
adapter.Fill(ds);
Cache["CustomerData"] = ds;
<-----------------------------------------
dgCustInfo.DataSource = ds;
ds = (DataSet)Cache["CustomerData"]; <------------------------------
dgCustInfo.DataBind();
conn.Close();
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote in message news:ub**************@TK2MSFTNGP03.phx.gbl...
>>Hi,

What you mean with caching data?

Are you refering to a dataset?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Antonio" <in**@awfulcards.comwrote in message
news:eN**************@TK2MSFTNGP02.phx.gbl...
Hi, everyone.

Can someone direct me to the "how-to" on cachine data from a sql to a
datagrid?

Thanks

Jul 4 '06 #5
The pattern for using the cache is like this:

1. Try to get the object from the cache.
2. If there was no object, get it from the database and add it to the cache.
3. Use the object.

Antonio wrote:
With the method below, ain't I accessing the database directly, everytime
the data is requested? What's the solution, if I don't want to query the
database directly everytime?

"Göran Andersson" <gu***@guffa.comwrote in message
news:OO**************@TK2MSFTNGP05.phx.gbl...
>Yes, that is how you store and retrieve values in the cache. Your code
doesn't do anything useful, though.

Antonio wrote:
>>Yes, Ignacio. This is what I have in the bindGrid method. See arrows.
Is it enough?

private void bindGrid()
{
SqlConnection conn = new SqlConnection
(ConfigurationSettings.AppSettings["SqlConnectionString"]);

conn.Open();

SqlCommand dataCommand = new SqlCommand();
dataCommand.Connection = conn;
dataCommand.CommandText = "SELECT GEM.customers.name AS [Institution
Name], "
+ "GEM.customers.CustomerSince AS [Customer Since], "
+ "GEM.contacts.name_first AS [First Name], "
+ "GEM.contacts.name_last AS [Last Name], "
+ "GEM.contacts.title AS [Contact Title], "
+ "GEM.customers.address_1 AS Address, "
+ "GEM.customers.city AS City, "
+ "GEM.customers.state AS State, "
+ "GEM.customers.province AS Province, "
+ "GEM.customers.zip_code AS [Zip Code], "
+ "GEM.customers.postal_code AS [Postal Code], "
+ "GEM.customers.country AS Country, "
+ "GEM.customers.phone AS Phone, "
+ "GEM.contacts.email AS [E-Mail Address], "
+ "GEM.customers.cust_id "
+ "FROM GEM.customers INNER JOIN GEM.config_usernames ON "
+ "GEM.customers.cust_id = GEM.config_usernames.cust_id INNER JOIN "
+ "GEM.contacts ON GEM.config_usernames.contact_id =
GEM.contacts.contact_id ORDER BY GEM.customers.name";

SqlDataAdapter adapter = new SqlDataAdapter(dataCommand);
DataSet ds = new DataSet();
adapter.Fill(ds);
Cache["CustomerData"] = ds;
<-----------------------------------------
dgCustInfo.DataSource = ds;
ds = (DataSet)Cache["CustomerData"]; <------------------------------
dgCustInfo.DataBind();
conn.Close();
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote in message news:ub**************@TK2MSFTNGP03.phx.gbl...
Hi,

What you mean with caching data?

Are you refering to a dataset?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Antonio" <in**@awfulcards.comwrote in message
news:eN**************@TK2MSFTNGP02.phx.gbl...
Hi, everyone.
>
Can someone direct me to the "how-to" on cachine data from a sql to a
datagrid?
>
Thanks
>
Jul 4 '06 #6

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

Similar topics

15
by: olle | last post by:
Hi folks. I learning asp.net and compare it with traditional asp and Access-developing. The issue is this one: 1/I have this Ms Acceess adp-project application that works fine on my Ms Sql...
1
by: moko | last post by:
I want to know whether 'dataset caching' is at the client end , or the server ? Similarly is an aspx page caching at the server or client ? Are there any 'gotchas' with caching ?
0
by: Troy Simpson | last post by:
Hi, I have a website which is made up of dynamic pages. Each page that's loaded has some code which looks at which template to load amongst other things, which causes the page to take a little...
3
by: Janaka | last post by:
Hi All, I'm having a problem with Page Output caching on a page that contains a DataGrid. Basically the page pulls up some data for sales information from the DB. Some of this has to be...
1
by: Leo Muller | last post by:
I am impressed by the caching performance of .NET. However, there is one major obstacle that I haven't managed to solve yet. What I want to do is the following: I have a normal site, and a...
3
by: DC | last post by:
Hi, (ASP.Net 1.1) is it possible to (programmatically and globally) deactivate page fragment caching? We have only two scenarios, development stage where we want caching off and testing where we...
5
by: Raj | last post by:
What is the purpose of file system caching while creating a tablespace? Memory on the test server gets used up pretty quickly after a user executes a complex query(database is already activated),...
2
by: George1776 | last post by:
All, I've recently upgraded our production ASP.NET/C# application from framework 1.1 to 2.0. Since then I've been plagued by out-of-memory errors and problems with the cache object (which may...
0
by: jason | last post by:
hi experts, support.microsoft.com/kb/917072 and http://msdn.microsoft.com/msdnmag/issues/06/07/WebAppFollies/ As pointed out in these articles, users might get session variables belong to...
4
by: Hermann | last post by:
My site is a bit slow showing the main page so I thought caching query result in PHP will improve performace. Then I read MySQL documentation and saw that MySQL does have a caching feature. So......
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.