Persoalization problem...
I have a problem. i am using personalization to load values on the login page.
protected void Login1_LoggedIn(object sender, EventArgs e)
{
string userName = Login1.UserName;
string password = Login1.Password;
string query1 = @"SELECT Security.SubscriberID, Security.UserTypeID, Subscribers.Lastname + ', ' + Subscribers.Firstname AS Fullname, Subscribers.Medid, Security.registrationnum FROM Security INNER JOIN Subscribers ON Security.SubscriberID = Subscribers.SubscriberID WHERE UserName = @UserName AND Pwd = @Password";
string conn1 = (string)ConfigurationManager.ConnectionStrings["typhoonConnectionString1"].ConnectionString;
SqlConnection myconn = new SqlConnection(conn1);
SqlCommand command = new SqlCommand(query1, myconn);
command.Parameters.AddWithValue("@UserName", userName);
command.Parameters.AddWithValue("@Password", password);
myconn.Open();
SqlDataReader reader = command.ExecuteReader();
reader.Read();
Profile.doctors.subscriberid = (String.Format("{0}", reader[0]));
Profile.doctors.usertype = (String.Format("{0}", reader[1]));
Profile.doctors.fullname = (String.Format("{0}", reader[2]));
Profile.doctors.medid = (String.Format("{0}", reader[3]));
Profile.doctors.registrationnum = (String.Format("{0}", reader[4]));
reader.Close();
myconn.Close();
}
I am reading Profile.doctors.fullname on my masterpage, but the problem is that it is not loading the correct data, de data is delay. If you sign with username1 i can not see the values, and if after that you singn with username2 the values are from the username1.
On my masterpage
LoginName name = (LoginName)LoginView2.FindControl("LoginName1");
name.FormatString = Profile.doctors.fullname;
But it is not working, i was testing using Response.Write(Profile.doctors.fullname); to see the data and it is alway wrong.
The query works perfect on sql analyzer, but i dont know why i am not loading the data on the profile on my web.config page.
Please help...
Luis
|