473,770 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Best approach to use different datasources - ?

I have a big database, a lot of tables, so I will have a lot of pages
where i create a new record.
There will be a lot of 'reference' items - let's say 'Create user' ->
'Select user type' <Dropdownlist-Admin, Partner, Client type A,
Client type B, Contract (is taken from UserTypes table)

Such 'reference' lists (based on 'reference' tables) should be used on
several pages, I will have a lot of reference tables.

So - what is the best practices of setting such things in ASP.NET?

Should I create some SPs with selecting data, where table name,
columns are parameters and then filling datasource dynamically or i
should create some 'static' datasources components, bound every to
specific table, and so on? Should i create some classes to hold data
from tables in memory for short 'reference' tables?

Please, tell me how YOU do it in your project (especially if it proved
to be effective)

Nov 2 '07 #1
9 1616

it's a pretty broad question ... but ... it sounds like you have a lot of
tables which will be used repeatedly in your application, which of course is
quite common. There are a lot of ways to handle this, but generally it
would not be a bad idea to create a data access layer (DAL) which can be
reused throughout the application by whatever pages might need it. You need
to think through how you will need to access the data: select data from
<some_tableby name, region, id, etc and set up the appropriate methods
which can accept parameters to return the data required

Visual Studio provides adequate tools to do all of this work ... you might
start by adding a DataSet to your web project and learning how to configure
it, which will take a little time if you haven't done it before ... what
you're doing is creating "Table Adapters," which are basically just classes
which provide data access methods

You don't have to use Visual Studio tools; nothing is stopping you from
writing your own data access classes ... if all of this sounds completely
foreign you should probably begin by reading some tutorials on the subject
.... a visit to http://www.asp.net is as good a place as any to begin

<al*******@gmai l.comwrote in message
news:11******** ************@z9 g2000hsf.google groups.com...
>I have a big database, a lot of tables, so I will have a lot of pages
where i create a new record.
There will be a lot of 'reference' items - let's say 'Create user' ->
'Select user type' <Dropdownlist-Admin, Partner, Client type A,
Client type B, Contract (is taken from UserTypes table)

Such 'reference' lists (based on 'reference' tables) should be used on
several pages, I will have a lot of reference tables.

So - what is the best practices of setting such things in ASP.NET?

Should I create some SPs with selecting data, where table name,
columns are parameters and then filling datasource dynamically or i
should create some 'static' datasources components, bound every to
specific table, and so on? Should i create some classes to hold data
from tables in memory for short 'reference' tables?

Please, tell me how YOU do it in your project (especially if it proved
to be effective)

Nov 2 '07 #2
if you have a number of utilty controls that will reappear on different
pages, then an appropriate way to handle this is to get all the data in the
Session_Start or Application_Sta rt handler, and store the datasets or
datatables in cache or Session with friendly names so the data can be re-used
on different pages without having to keep going back to the database every
time. Session being user-specific, Cache being application -wide.
-- Peter
// It works on my machine!
http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"al*******@gmai l.com" wrote:
I have a big database, a lot of tables, so I will have a lot of pages
where i create a new record.
There will be a lot of 'reference' items - let's say 'Create user' ->
'Select user type' <Dropdownlist-Admin, Partner, Client type A,
Client type B, Contract (is taken from UserTypes table)

Such 'reference' lists (based on 'reference' tables) should be used on
several pages, I will have a lot of reference tables.

So - what is the best practices of setting such things in ASP.NET?

Should I create some SPs with selecting data, where table name,
columns are parameters and then filling datasource dynamically or i
should create some 'static' datasources components, bound every to
specific table, and so on? Should i create some classes to hold data
from tables in memory for short 'reference' tables?

Please, tell me how YOU do it in your project (especially if it proved
to be effective)

Nov 2 '07 #3
Ok, thanks... But what total number of records in dataset it makes
sense to store in cache? Hundreds? More?

Nov 5 '07 #4
<al*******@gmai l.comwrote in message
news:11******** *************@1 9g2000hsx.googl egroups.com...
Ok, thanks... But what total number of records in dataset it makes
sense to store in cache? Hundreds? More?
That will depend on the amount of RAM your webserver can spare... Each case
is different...

However, generally speaking, datatables don't bloat very much - if you've
got 1,000 records of 200 bytes each, that won't represent very much more
than 200k on the server - chances are, you can spare that quite easily...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 5 '07 #5
Thanks, guys.
But topic is going further....
Ok, i tried to create cache dataset objects in application_sta rt
method, but...
cache object is still unavailable there?? Error says: cache is a type,
but used as a variable...
//=============== ====
DataSet ds = new DataSet();
DB2DataAdapter da = new DB2DataAdapter( );

DB2Connection conn = new DB2Connection(c onnectionString );
DB2Command cmduserTypes = new DB2Command("SEL ECT NAME AS ID, NAME
FROM Wiz_UserTypes", conn);
DB2Command cmdAdmins = new DB2Command("SEL ECT ID, NAME FROM
Wiz_Admins", conn);
DB2Command cmdPartners = new DB2Command("SEL ECT ID, NAME FROM
Wiz_Partners", conn);
DB2Command cmdEmployees = new DB2Command("SEL ECT ID, NAME FROM
Wiz_Employees", conn);
DB2Command cmdContracts = new DB2Command("SEL ECT ID, NAME FROM
Wiz_Contracts", conn);

try
{
conn.Open();
da.SelectComman d = cmduserTypes;
da.Fill(ds);
Cache["userTypes"] = ds;
da.SelectComman d = cmdAdmins;
da.Fill(ds);
Cache["admins"] = ds;
da.SelectComman d = cmdPartners;
da.Fill(ds);
Cache["partners"] = ds;
da.SelectComman d = cmdEmployees;
da.Fill(ds);
Cache["employees"] = ds;
da.SelectComman d = cmdContracts;
da.Fill(ds);
Cache["contracts"] = ds;
//=============== ====

If i do the same assignment in page_load method of some page - it's
ok.

But Peter was right, i guess: there are _several_ places I would
access some my tables from, so I'd better cache all datasets in _one_
place once and change this data explicitly on the pages where this
data could change: usually these are admin pages... So
application_sta rt seemed a best place...

Nov 5 '07 #6
<al*******@gmai l.comwrote in message
news:11******** *************@o 80g2000hse.goog legroups.com...
Cache["contracts"] = ds;
Application["contracts"] = ds;
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 5 '07 #7
Application[] is what i used for 'tiny' settings like connection
string. Is it really a good idea to use application[] for storing
datasets instead of cache?

Btw, i got exception in global.asax file and put breakpoint to trace
it next time I run debug, but somehow breakpoint has not fired (right
away i've seen my login page, bypassing global.asax code) :( Why it
could be?

Nov 6 '07 #8
<al*******@gmai l.comwrote in message
news:11******** **************@ d55g2000hsg.goo glegroups.com.. .
Application[] is what i used for 'tiny' settings like connection
string. Is it really a good idea to use application[] for storing
datasets instead of cache?
Unless you're using a web farm, there's not much difference for the data
that you want to cache...

The main difference between Application and Cache is that Cache has the
concepts of timeout and priority, but Application doesn't:
http://www.codeproject.com/aspnet/ca...ntinaspnet.asp
Btw, i got exception in global.asax file and put breakpoint to trace
it next time I run debug, but somehow breakpoint has not fired (right
away i've seen my login page, bypassing global.asax code) :( Why it
could be?
Application_Sta rt fires only when the application starts... If your
application hasn't stopped, it won't fire as a result of the next session...

Simply recycle your application and it will fire again...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 6 '07 #9
Thanks. One more question (going further and further... :) )

I thought about considering some 'reference table' data as enum types
(i.e. using userTypes.PARTN ER instead of "PARTNER" string in switch
condition).
I even tried function for type generation via
ModuleBuilder.D efineEnum, but... i totally forgot, that it's a DYNAMIC
type and VS won't let me compile it...
There's still a save method for making dll, so i can't put this into
pre_event, but maybe it's getting too complicated and slow, what would
you say?

So... what is a best approach for using error-proof & neat
representation of 'enum-like' db data amongst the pages?

Nov 6 '07 #10

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

Similar topics

136
9456
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
0
1568
by: Greg | last post by:
Anyone having issues with their object datasources appearing and vanishing from the datasource browser? I create an object for binding as a datasource in my App_Code folder, compile my web project and it appears in the datasources in the report designer. Then I will make an aspx, setup a reportviewer control for my new report, go back to the rdlc and the object datasource sometimes just vanishes. I refresh, no luck.
4
1401
by: markrush | last post by:
if i have 2 datasources with different table names and column headers that i want to merge i.e. "ptitle" and "name" whats the best way of doing this? are there any standard routines or should i use something intermediary like xml? mark
3
1816
by: cbrown | last post by:
I am rebuilding an existing application that relies on an SQL DB. The app is a scheduling/employee management program. My question pertains to best practices in dotnet and database. I use a 3 tier model and have custom classes for things like Employees. What comes to question is when I load an Employee from my DB, I populate the properties of the object with the data in the dataset. When I want to view the employee on a form, i bind...
16
2818
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and efficient navigating within Visual Studio 2005. Let's say your project (or solution) has dozens of forms and hundreds or even thousands of routines. Two Questions: 1) BUILT-IN to Visual Studio 2005. What ideas do you have to quickly
3
7243
by: jobs | last post by:
I've got a gridview that does not have a datasourceid assigned in the markup. I'd like to switch between two datasources in the codebehind. when I do switch, I first reset the the gridviewx.datasource = nothing and gridviewx.datasourceid = nothing before setting it to gridviewx.datasource = newdatasoruceid and then rebinding. All appears to work well until I try to excute a delete command that
19
3162
by: cpnet | last post by:
I'm using VS2005, C#, ASP.NET 2.0. I'm trying to create a report using SQL Reporting Services (to be used in local mode so I don't have to deal with SQL Server). When I create a new report in my website, nothing shows up in the Website Data Sources window. I added a few different strongly-typed Datasets to my website, and they don't show up. The only way I could get anything to show up was to create a new class that's derived from a...
5
1395
by: gw7rib | last post by:
I'm writing a program which has "notes" - these can appear on the screen as windows with text in. It is possible to create an "index note" - at present, this will contain a list of the titles (or other data, you can choose) of some or all of the notes - you can choose the selection criteria. Thus you can create notes to store any text you want to, in a relatively free manner, but you can easily fish out all the notes relating to some...
0
1129
by: RN | last post by:
All, I have a datagridview control displaying two columns(part number and revision). Both columns are read only. the revision colum is a datagridviewcombobox colum. I would like for the items in the comboboxes to reflect the revisions availble for that particular part number. Is this possible? Can different DataGridViewCombobox's in the same DataGridviewComboboxcolumn have different items and/ or datasources? If so how is this...
0
9618
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9906
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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 we have to send another system

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.