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
sumaira manzoor hussain khan
NA
241
250.9k
How we can login in c-sharp
Aug 30 2011 3:19 AM
hello ;
my question is, how we can create login in c-sharp. it means, if i enter username and password and then i press login button. the name and password compare from the table of "login" that are exist in the sql database . if username and password will be match from the username and password of the database table then display on the top of the web page "welcome MR OR MS XYZ". if the username and password are not match then display "invalid". i am writing this code in the login button. can u help me ?
protected void Button_login_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("select * from login where [user_name]='"+TextBox_user_name.Text+"' and [password]='"+TextBox_password.Text+"'");
cmd.Connection = connection.get();
cmd.Parameters.AddWithValue(" username ",TextBox_user_name.Text);
cmd.Parameters.AddWithValue(" password",TextBox_password.Text);
int c = cmd.ExecuteNonQuery();
if (c == 0)
{
Label_result.Text = "invalid user name and password";
}
else
Label_display_user_name.Text = "WELLCOME ";
}
regards
sumaira
Reply
Answers (
5
)
How to count the data in sql server using data adapter?
How to count the data in sql server using csharp code?