Database Table Verses DropDownList

L

Leon

What is the best way to store small sets of look-up data for my web
application in the database (sql2000) or in a dropdownlist control in my web
form?
Or is it a question of how much data I want to type over and over again.

Example:
TableName - YearMonths
MonthID (1, 2, 3, 4, etc)
YearMonth (Jan, Feb, Mar, Apr, etc)

TableName - Gender
GenderID (M, F)
Description (Male, Female)

TableName - MonthDate
MonthDate (1, 2, 3, 4,......31)

Note: All Interaction with the database is done from the web Interface.

Thanks!
 
K

Karl Seguin

I'm not 100% sure what you are asking, but I think the answer is to make
liberal use of the cache:

public sealed class LookupUtility{
private LookupUtility(){}

public static DataTable GetYears(){
string cacheKey = "getYears";
DataTable dt = (DataTable)HttpRuntime.Cache[cacheKey];
if (dt == null){
dt = getFromDataBase();
HttpRuntime.Cache.Insert(cacheKey, dt, null, DateTime.MaxValue,
TimeSpan.Zero);
}
return dt;
}
}


things you might want to consider is to create a lookup class and a
lookupcollection so you aren't passing around weakly-typed datatables
around...and do you really need to hit the database to get the YearMonth and
MonthDate? .Net has built-in capabilities for that...


Karl
 
L

Leon

This is what I'm asking:

do I really need to hit the database to get the YearMonth and
MonthDate? What .Net built-in capabilities do the following...

Karl Seguin said:
I'm not 100% sure what you are asking, but I think the answer is to make
liberal use of the cache:

public sealed class LookupUtility{
private LookupUtility(){}

public static DataTable GetYears(){
string cacheKey = "getYears";
DataTable dt = (DataTable)HttpRuntime.Cache[cacheKey];
if (dt == null){
dt = getFromDataBase();
HttpRuntime.Cache.Insert(cacheKey, dt, null, DateTime.MaxValue,
TimeSpan.Zero);
}
return dt;
}
}


things you might want to consider is to create a lookup class and a
lookupcollection so you aren't passing around weakly-typed datatables
around...and do you really need to hit the database to get the YearMonth
and
MonthDate? .Net has built-in capabilities for that...


Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/


Leon said:
What is the best way to store small sets of look-up data for my web
application in the database (sql2000) or in a dropdownlist control in my web
form?
Or is it a question of how much data I want to type over and over again.

Example:
TableName - YearMonths
MonthID (1, 2, 3, 4, etc)
YearMonth (Jan, Feb, Mar, Apr, etc)

TableName - Gender
GenderID (M, F)
Description (Male, Female)

TableName - MonthDate
MonthDate (1, 2, 3, 4,......31)

Note: All Interaction with the database is done from the web Interface.

Thanks!
 
K

Karl Seguin

Well, you can do things like:

DateTime start = new DateTime(2000,1,1);
for (int i = 0; i < 12; ++i) {
Response.Write(String.Format("{0:MMMM}", start.AddMonths(i)));
}

The main reason I like it better is that it'll automatically display the
month name in the culture you have it set..so if you switch the culture to
fr-CA, it'll automatically display "janvier", "fevrier" ... and so on


Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/


Leon said:
This is what I'm asking:

do I really need to hit the database to get the YearMonth and
MonthDate? What .Net built-in capabilities do the following...

Karl Seguin said:
I'm not 100% sure what you are asking, but I think the answer is to make
liberal use of the cache:

public sealed class LookupUtility{
private LookupUtility(){}

public static DataTable GetYears(){
string cacheKey = "getYears";
DataTable dt = (DataTable)HttpRuntime.Cache[cacheKey];
if (dt == null){
dt = getFromDataBase();
HttpRuntime.Cache.Insert(cacheKey, dt, null, DateTime.MaxValue,
TimeSpan.Zero);
}
return dt;
}
}


things you might want to consider is to create a lookup class and a
lookupcollection so you aren't passing around weakly-typed datatables
around...and do you really need to hit the database to get the YearMonth
and
MonthDate? .Net has built-in capabilities for that...


Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/


Leon said:
What is the best way to store small sets of look-up data for my web
application in the database (sql2000) or in a dropdownlist control in
my
web
form?
Or is it a question of how much data I want to type over and over again.

Example:
TableName - YearMonths
MonthID (1, 2, 3, 4, etc)
YearMonth (Jan, Feb, Mar, Apr, etc)

TableName - Gender
GenderID (M, F)
Description (Male, Female)

TableName - MonthDate
MonthDate (1, 2, 3, 4,......31)

Note: All Interaction with the database is done from the web Interface.

Thanks!
 
L

Leon

Thanks Karl!

Karl Seguin said:
Well, you can do things like:

DateTime start = new DateTime(2000,1,1);
for (int i = 0; i < 12; ++i) {
Response.Write(String.Format("{0:MMMM}", start.AddMonths(i)));
}

The main reason I like it better is that it'll automatically display the
month name in the culture you have it set..so if you switch the culture to
fr-CA, it'll automatically display "janvier", "fevrier" ... and so on


Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/


Leon said:
This is what I'm asking:

do I really need to hit the database to get the YearMonth and
MonthDate? What .Net built-in capabilities do the following...

Karl Seguin said:
I'm not 100% sure what you are asking, but I think the answer is to
make
liberal use of the cache:

public sealed class LookupUtility{
private LookupUtility(){}

public static DataTable GetYears(){
string cacheKey = "getYears";
DataTable dt = (DataTable)HttpRuntime.Cache[cacheKey];
if (dt == null){
dt = getFromDataBase();
HttpRuntime.Cache.Insert(cacheKey, dt, null, DateTime.MaxValue,
TimeSpan.Zero);
}
return dt;
}
}


things you might want to consider is to create a lookup class and a
lookupcollection so you aren't passing around weakly-typed datatables
around...and do you really need to hit the database to get the
YearMonth
and
MonthDate? .Net has built-in capabilities for that...


Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/


What is the best way to store small sets of look-up data for my web
application in the database (sql2000) or in a dropdownlist control in my
web
form?
Or is it a question of how much data I want to type over and over again.

Example:
TableName - YearMonths
MonthID (1, 2, 3, 4, etc)
YearMonth (Jan, Feb, Mar, Apr, etc)

TableName - Gender
GenderID (M, F)
Description (Male, Female)

TableName - MonthDate
MonthDate (1, 2, 3, 4,......31)

Note: All Interaction with the database is done from the web
Interface.

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top