Click here to Skip to main content
15,742,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,
I created a,C# application that uses Add/update/delete from a sql server 2005 database table. Is there a way for me to temporarily store the data so that my program does not have to repeatedly make server calls for the same set of information. I need the results to be universally available until the program closes.
This is what I have so far and I am not sure where to go next:
public DataTable getsanctioneremail(string company, string locno, string Empcode)
            string sConnString = "";
            sConnString = getConnectionStringForPerdb(company);
            SqlConnection conn = new SqlConnection(sConnString);
            SqlDataAdapter dAd = new SqlDataAdapter();
            SqlCommand dCmd = new SqlCommand("LeaveApp_getSanctionEmail", conn);
            dAd.SelectCommand = dCmd;
            dAd.SelectCommand.CommandType = CommandType.StoredProcedure;
            DataSet dSet = new DataSet();
                dCmd.Parameters.AddWithValue("@company", company);
                dCmd.Parameters.AddWithValue("@locno", locno);
                dCmd.Parameters.AddWithValue("@Emp_Num", Empcode);
                dAd.Fill(dSet, "tblgetEmpemail");
                return dSet.Tables["tblgetEmpemail"];
            {   dSet.Dispose();
                conn.Dispose();   }

if possible please send me the code.
Updated 8-Aug-11 1:30am

You have declare globel dataset varible as DataSet type..
And you can access this dataset varible where you want ..
Share this answer
Just move your DataSet to a class level private variable instead of a local one, and do not Dispose it.
Alternatively, store the DataTable you return from getsanctioneremail in a class level private variable.
Share this answer
If you use you can store the data in sessionvariables.
These Sessionvariable automatic destroys by closing the website or running into timeout.

for examlpe you have your data in dSet:
Session["DBData"] = dSet;

Now you have all your Data in a temporary Sessionvariable.
You can read the data like this:

DataSet ds = (DataSet)Session["DBData"];
Share this answer
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900