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
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Login Function of C#
Hammad Maqbool
Jul 22
2015
Code
8.2
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
public
bool
_Login(
string
Username,
string
Password,
string
connection,
string
TableName)
{
string
_username = Username;
string
_password = Password;
string
_Query =
"SELECT * FROM'"
+TableName+
"' WHERE Username='"
+_username+
"'AND Password='"
+_password+
"'"
;
string
_Connection = connection;
SqlConnection Con =
new
SqlConnection(_Connection);
Con.Open();
SqlCommand cmd =
new
SqlCommand(_Query,Con);
SqlDataReader Dr = cmd.ExecuteReader();
while
(Dr.Read())
{
if
(_username == Dr[
"Username"
].ToString() && _password == Dr[
"Password"
].ToString())
{
return
true
;
}
}
return
false
;
}
Login
C#
Asp.NET
SQLLogin