Click here to Skip to main content
15,887,444 members
Home / Discussions / C#
   

C#

 
AnswerRe: Extract All text values Pin
0x3c06-Jan-09 20:10
0x3c06-Jan-09 20:10 
QuestionAdding resource at runtime Pin
Xmen Real 6-Jan-09 15:00
professional Xmen Real 6-Jan-09 15:00 
AnswerRe: Adding resource at runtime Pin
N a v a n e e t h6-Jan-09 15:23
N a v a n e e t h6-Jan-09 15:23 
GeneralRe: Adding resource at runtime Pin
Xmen Real 6-Jan-09 15:26
professional Xmen Real 6-Jan-09 15:26 
GeneralRe: Adding resource at runtime Pin
N a v a n e e t h6-Jan-09 15:40
N a v a n e e t h6-Jan-09 15:40 
GeneralRe: Adding resource at runtime Pin
Xmen Real 6-Jan-09 15:43
professional Xmen Real 6-Jan-09 15:43 
AnswerRe: Adding resource at runtime Pin
Jon Rista6-Jan-09 15:45
Jon Rista6-Jan-09 15:45 
QuestionCaching Pin
CrimeanTurtle20086-Jan-09 11:41
CrimeanTurtle20086-Jan-09 11:41 
Hi Guys,

Ive tried to do a simple caching application and have traced/debugged it, however it does not seem to store the datatable into the cache.
No matter how many times I load it it always retrieves the data from the Database instead of the cache after refreshing the page. Could someone interpret my code, Cheers.

public partial class Caching_ApplicationCaching : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        

        DataSet ds = new DataSet();
        string query = "SELECT FIRSTNAME, LASTNAME FROM CUSTOMERS";

        DataView source = (DataView)Cache["Client"];

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString()))
            {
                
                if (source == null)
                {



                    conn.Open();
                    SqlCommand command = new SqlCommand(query, conn);

                    SqlDataAdapter adapter = new SqlDataAdapter(command);
                    command.CommandType = CommandType.Text;
                    
                    adapter.Fill(ds, "Customers");
                    Cache.Insert("Client", ds);

                    foreach (DataRow item in ds.Tables["Customers"].Rows)
                    {
                        string Firstname = item["FirstName"].ToString();
                    

                        DropDownList1.Items.Add(Firstname);

                        source = new DataView(ds.Tables["FirstName"]);
                        Cache["Client"] = source;
                       

                    }
                }
                else
                {
                    DropDownList1.DataSource = source;
                    DropDownList1.DataBind();
                }
                    


        }


       

    
    }
}

AnswerRe: Caching Pin
Guffa6-Jan-09 11:57
Guffa6-Jan-09 11:57 
GeneralRe: Caching Pin
CrimeanTurtle20086-Jan-09 12:08
CrimeanTurtle20086-Jan-09 12:08 
GeneralRe: Caching Pin
Colin Angus Mackay6-Jan-09 12:32
Colin Angus Mackay6-Jan-09 12:32 
GeneralRe: Caching Pin
Guffa6-Jan-09 12:45
Guffa6-Jan-09 12:45 
GeneralRe: Caching Pin
CrimeanTurtle20086-Jan-09 12:55
CrimeanTurtle20086-Jan-09 12:55 
AnswerRe: Caching Pin
Jon Rista6-Jan-09 14:29
Jon Rista6-Jan-09 14:29 
GeneralRe: Caching Pin
moon_stick6-Jan-09 22:24
moon_stick6-Jan-09 22:24 
GeneralRe: Caching Pin
Jon Rista7-Jan-09 12:00
Jon Rista7-Jan-09 12:00 
QuestionWhen to declare windows service application settings Pin
KaptinKrunch6-Jan-09 10:27
KaptinKrunch6-Jan-09 10:27 
AnswerRe: When to declare windows service application settings Pin
Not Active6-Jan-09 10:45
mentorNot Active6-Jan-09 10:45 
AnswerRe: When to declare windows service application settings Pin
Sunny Ahuwanya6-Jan-09 10:46
Sunny Ahuwanya6-Jan-09 10:46 
Questionwhat's wrong, Object reference not set to an instance of an object. Pin
suni_dotnet6-Jan-09 9:47
suni_dotnet6-Jan-09 9:47 
AnswerRe: what's wrong, Object reference not set to an instance of an object. Pin
Jon Rista6-Jan-09 10:00
Jon Rista6-Jan-09 10:00 
GeneralRe: what's wrong, Object reference not set to an instance of an object. Pin
suni_dotnet6-Jan-09 10:17
suni_dotnet6-Jan-09 10:17 
GeneralRe: what's wrong, Object reference not set to an instance of an object. Pin
Jon Rista6-Jan-09 14:34
Jon Rista6-Jan-09 14:34 
AnswerRe: what's wrong, Object reference not set to an instance of an object. Pin
Pete O'Hanlon6-Jan-09 10:15
mvePete O'Hanlon6-Jan-09 10:15 
GeneralRe: what's wrong, Object reference not set to an instance of an object. Pin
suni_dotnet6-Jan-09 10:22
suni_dotnet6-Jan-09 10:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.