TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abhimanyu K Vatsa
NA
40.4k
21.4m
searching record
Jun 15 2010 10:29 AM
I have a login project and it is running successfully but after login it is not saving the login session and because of this, i am unable to access the secure page. How to save the login session, please help me. Here is coding which i am using for the same...
//this is the code behind the login button click event
protected void log_Click(object sender, EventArgs e)
{
SqlDataSource sds = new SqlDataSource();
sds.ConnectionString = ConfigurationManager.ConnectionStrings["myDbConnectionString1"].ToString();
sds.SelectParameters.Add("username", TypeCode.String, this.username.Text);
sds.SelectParameters.Add("password", TypeCode.String, this.password.Text);
sds.SelectCommand = "SELECT * FROM [myTb] WHERE [username] = @username AND [password] = @password";
DataView dv = (DataView)sds.Select(DataSourceSelectArguments.Empty);
if (dv.Count == 0)
{
this.lblinfo.ForeColor = System.Drawing.Color.Red;
this.lblinfo.Text = "Invalid username and password!";
return;
}
else
{
// Creating session for user
this.Session["username"] = dv.Row["username"].ToString();
this.Session["password"] = dv.Row["password"].ToString();
Response.Redirect("securepage/SecurePage.aspx");
}
}
What I have to use instead of red colored texts to work.
Help me !
Reply
Answers (
2
)
querry is returning zero eventhough data is present in data base
event based question......