knowledgehungry Posted July 3, 2007 Share Posted July 3, 2007 HOw can i save the database for use across multiple request for the pages in my site? Link to comment Share on other sites More sharing options...
aspnetguy Posted July 4, 2007 Share Posted July 4, 2007 I am not sure what you mean. Do you mean you want to query the database once and then use the results over multiple pages? You couls save the data in sessions but unless it is a huge query then it would be easier to just query the database again. Also if it is a huge result set then saving it in sessions may be difficult. Link to comment Share on other sites More sharing options...
knowledgehungry Posted July 9, 2007 Author Share Posted July 9, 2007 I am not sure what you mean. Do you mean you want to query the database once and then use the results over multiple pages? You couls save the data in sessions but unless it is a huge query then it would be easier to just query the database again. Also if it is a huge result set then saving it in sessions may be difficult.yes excatly .whatever u have understood is true. i exactly want the solution for this ! Link to comment Share on other sites More sharing options...
aspnetguy Posted July 10, 2007 Share Posted July 10, 2007 you could create a class something like the example below to manage your stored data public class DataStorage{ public DataStorage() { } private static DataSet StoreData() { DataSet ds = new DataSet(); SqlConnection conn = new SqlConnection("Connection String"); SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM MyTable", conn); conn.Open(); da.Fill(ds); conn.Close(); Session["StoredDataSet"] = ds; return ds; } public static DataSet StoredDatSet { get { object obj = Session["StoredDataSet"]; if(obj != null) return (DataSet) obj; DataSet ds = DataStorage.StoreData(); return ds; } }} Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.