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
Ash Gudi
NA
1
1.8k
Invalid database rows returned
Aug 5 2010 3:27 PM
Hi Guys,
I have just started to use ASP.net and was struck with the following lines of code. Basically i am trying to implement the login page. What i need to do is to compare the userinput against the username in the database and if it matches to a particular string called Ashwin then redirect him to the admin page.
However that is not happening. When i tried to debug the program using breakpoint what i have realized is the database is returning -1 for the RecordsAffected property.
My database is a simple table with two columns, userName and password. Pls help. Code is given belwo.
string
loginSt =
"Select * from userDetails where userName = '"
+ TxtUser.Text +
"'"
;
loginSt +=
"AND"
+
" "
+
"password = '"
+ TxtPwd.Text +
"'"
;
SqlConnection
con =
new
SqlConnection
(connectionString);
SqlCommand
cmd =
new
SqlCommand
(loginSt, con);
SqlDataReader
reader;
try
{
con.Open();
reader = cmd.ExecuteReader();
reader.Read();
if
( reader.GetString(0) ==
"Ashwin"
)
{
Response.Redirect(
"AdminPage.aspx"
);
}
else
{
Response.Redirect(
"About.aspx"
);
}
Reply
Answers (
1
)
manipulate explorer.exe
stringbuilder example