Tapping into cache object
Hi and thanks for taking a moment to read this. I have a simple login page that creates a dataset and cache's it on login. I would then like to take the user to another page that displays the data. (Be it with a form view, data view, it really doesn't matter to me) Below is my code. Is there anyway I can take the Source object (Which is my cache object) and display the data on my updateinfo .aspx ? Any advice would be greatly appreciated.
--Jason
public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
DataView Source;
int RowCount;
{
SqlConnection myConnection = new SqlConnection("Server=Jason; database=AddressBook; user id=dummy; password=stupid;");
SqlCommand myCommand = new SqlCommand("Select * From Contacts Where username=@username AND password=@password", myConnection);
myCommand.Parameters.Add("@username", txtUsername.Text);
myCommand.Parameters.Add("@password", txtpassword.Text);
DataSet ds = new DataSet();
SqlDataAdapter myAdapter = new SqlDataAdapter(myCommand);
myAdapter.Fill(ds, "Contacts");
// Create the Cache object named 'Source'
Source = new DataView(ds.Tables["Contacts"]);
Cache["MyDataSet"] = Source;
RowCount = Source.Table.Rows.Count;
if (RowCount > 0)
{
Response.Redirect("Updateinfo.aspx");
}
else
{
lblError.Visible = true;
}
}
}
}
|