this is my code
namespace facebookDemo
{
public partial class Verification2 : System.Web.UI.Page
{
public string name;
public string caregroupID;
public string staffNumber;
//public string name2;
public string uid;
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Cookies["txtMatricNo"] != null && Request.Cookies["txtSCardNo"] != null)
{
txtMatricNo.Text = Server.HtmlEncode(Request.Cookies["txtMatricNo"].Value);
txtSCardNo.Text = Server.HtmlEncode(Request.Cookies["txtSCardNo"].Value);
//btnProceed2_Click;
}
}
protected void btnProceed2_Click(object sender, EventArgs e)
{
if (CheckBox1.Checked == true)
{
/* if (Request.Cookies["txtMatricNo"] != null && Request.Cookies["txtSCardNo"] != null)
{
Response.Cookies["txtMatricNo"].Expires = DateTime.Now.AddDays(-1d);
Response.Cookies["txtSCardNo"].Expires = DateTime.Now.AddDays(-1d);
}*/
Response.Cookies["txtMatricNo"].Value = txtMatricNo.Text;
Response.Cookies["txtSCardNo"].Value = txtSCardNo.Text;
Response.Cookies["txtMatricNo"].Expires = DateTime.Now.AddSeconds(50);
Response.Cookies["txtSCardNo"].Expires = DateTime.Now.AddSeconds(50);
}
try
{
string connectString = ConfigurationManager.AppSettings["DatabaseConnectionString"];
SqlConnection con = new SqlConnection(connectString);
con.Open();
string thesql = "select * from student where studMatricNumber='" + txtMatricNo.Text + "' and studCardNumber = '" + txtSCardNo.Text + "';";
SqlCommand cmd = new SqlCommand(thesql, con);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
//name2 = reader["uid"].ToString();
//Session["name2"] = name2;
name = reader["studName"].ToString();
Session["name"] = name;
caregroupID = reader["caregroupID"].ToString();
Session["caregroupID"] = caregroupID;
uid = reader["uid"].ToString();
Session["uid"] = uid;
//Response.Redirect("~/Profile2.aspx");
}
reader.Close();
con.Close();
}
catch (Exception err)
{
// myLabel2.Text = "Error: " + err;
}
try
{
string connectString2 = ConfigurationManager.AppSettings["DatabaseConnectionString"];
SqlConnection con2 = new SqlConnection(connectString2);
con2.Open();
string thesql2 = "Update student set uid ='" + Facebook.Web.FacebookHttpContext.Current.Session.Uid + " 'WHERE studMatricNumber='" + txtMatricNo.Text + "'";
//Update Student set studEmail ='l;jkkljhj' , studhandphone='3213231' WHERE studName ='lionel lau'
SqlCommand cmd2 = new SqlCommand(thesql2, con2);
cmd2.ExecuteNonQuery();
con2.Close();
Response.Redirect("~/Profile2.aspx");
}
catch (Exception err)
{
//myLabel.Text = "Error: " + err;
}
Response.Redirect("~/Profile2.aspx");
}
}
}

New Topic/Question
Reply




MultiQuote





|