Your login attempt was not successful. Please try again PROBLEM

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2009
Posts: 2
Reputation: nikolas8 is an unknown quantity at this point 
Solved Threads: 0
nikolas8 nikolas8 is offline Offline
Newbie Poster

Your login attempt was not successful. Please try again PROBLEM

 
0
  #1
Apr 22nd, 2009
Hi,

I have a problem with my login control. I changed the code in order to use my own database (SQL Server 2005) and no matter what i do i get the message "Your login attempt was not successful. Please try again. "!!!

in the web.config file i chose my own connection string leading to my database, so i don't use the default database for the login authorization.

Do i have to change anything else in there?

Check out my code below

Please anyone who can help i really appreciate it!!!!!!!

When I debugged the code I get the exception on the line 55



  1. public partial class _Login : System.Web.UI.Page
  2. {
  3. protected void Page_Load(object sender, EventArgs e)
  4. {
  5.  
  6.  
  7. }
  8.  
  9.  
  10. protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
  11. {
  12. try
  13. {
  14. string uname = Login1.UserName.Trim(); //Get the username from the control
  15. string password = Login1.Password.Trim(); //get the Password from the control
  16. bool flag = AuthenticateUser(uname, password);
  17. if (flag == true)
  18. {
  19. e.Authenticated = true;
  20. Login1.DestinationPageUrl = "Admin.aspx";
  21.  
  22. }
  23. else
  24. {
  25. e.Authenticated = false;
  26.  
  27. }
  28. }
  29. catch (Exception)
  30. {
  31.  
  32. e.Authenticated = false;
  33. }
  34. }
  35.  
  36. private bool AuthenticateUser(string uname, string password)
  37. {
  38.  
  39. bool bflag = false;
  40. string connString = "Data Source = localhost; Initial Catalog = Telemedicine; User Id=sa; Password=sa;";
  41.  
  42. string strSQL = "select * from Administrator where UserName =’" + uname + "‘ AND Password =’" + password + "‘";
  43.  
  44. DataSet userDS = new DataSet();
  45. SqlConnection m_conn;
  46. SqlDataAdapter m_dataAdapter;
  47. SqlCommand m_Command;
  48.  
  49.  
  50. try
  51. {
  52. m_conn = new SqlConnection(connString);
  53. m_conn.Open();
  54. m_dataAdapter = new SqlDataAdapter(strSQL, m_conn);
  55. m_dataAdapter.Fill(userDS);
  56. m_conn.Close();
  57. }
  58. catch (Exception ex)
  59. {
  60.  
  61. userDS = null;
  62. }
  63. if (userDS != null)
  64. {
  65. if (userDS.Tables[0].Rows.Count > 0)
  66.  
  67. bflag = true;
  68. }
  69. return bflag;
  70. }
  71.  
  72. }




thank u very much

Nikolas
Last edited by peter_budo; Apr 25th, 2009 at 5:29 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 115
Reputation: ninjaimp is an unknown quantity at this point 
Solved Threads: 6
ninjaimp ninjaimp is offline Offline
Junior Poster

Re: Your login attempt was not successful. Please try again PROBLEM

 
0
  #2
Apr 23rd, 2009
check t make sure that all your tables column names are the same if you want to use the built in login code.

Else you could just as easy build your own if you have the table already in place.
Please mark this post as 'Solved' if it has helped and fixed your issue.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 2
Reputation: nikolas8 is an unknown quantity at this point 
Solved Threads: 0
nikolas8 nikolas8 is offline Offline
Newbie Poster

Re: Your login attempt was not successful. Please try again PROBLEM

 
0
  #3
Apr 23rd, 2009
Thanks ninjaimp.

I found the problem. It was that i had to give permission to access the tables in my db. I didn't know that because i was able to connect to the server but i didn't have access to the db tables.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 370
Reputation: greeny_1984 is an unknown quantity at this point 
Solved Threads: 29
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz

Re: Your login attempt was not successful. Please try again PROBLEM

 
0
  #4
Apr 25th, 2009
Hi,
If your problem is solved mark this thread as solved so that fellow posters can concentrate on other posts.
If u r query is achieved,mark the thread as solved

Live and Let Live
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC