dataset as a cache in C# windows application
Posted on 2006-06-20
I am using a dataset to store infrequently changing data in a C# Windows application. I am not sure how long this data can be stored in the dataset without accessing the database again. Please see below the relevant portion of the code. When the project is run, the stored data can be accessed without connecting to the database. But this project will be run a lot of times during a day. I want to get the data from the database only when the project is run the first time and then on subsequent runs, I dont want to connect to the database. How should I do that? Please help. It's urgent. Thank you.
static void Main()
cache c = new cache();
// At this point, I can access the stored data without connecting to database.
public static ds dataset;
if (dataset == null)
dataset = new ds();
OdbcDataAdapter odba = new OdbcDataAdapter("select * from product", odbcConn);