943,832 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 3241
  • ASP.NET RSS
Apr 22nd, 2009
0

Your login attempt was not successful. Please try again PROBLEM

Expand Post »
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



asp.net Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nikolas8 is offline Offline
2 posts
since Apr 2009
Apr 23rd, 2009
0

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

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.
Reputation Points: 22
Solved Threads: 9
Junior Poster
ninjaimp is offline Offline
129 posts
since Apr 2008
Apr 23rd, 2009
0

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

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nikolas8 is offline Offline
2 posts
since Apr 2009
Apr 25th, 2009
0

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

Hi,
If your problem is solved mark this thread as solved so that fellow posters can concentrate on other posts.
Reputation Points: 25
Solved Threads: 29
Posting Whiz
greeny_1984 is offline Offline
372 posts
since Apr 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: GridView Control
Next Thread in ASP.NET Forum Timeline: Refreshing a dropdownlist in a FormView Template





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC