944,052 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 3006
  • ASP.NET RSS
Oct 22nd, 2006
0

Asp.Net Login Page Problem?

Expand Post »
VB.NET Code behind:
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dbconn As SqlConnection
Dim dbcommand As SqlDataAdapter
Dim dslogin As New DataSet
dbconn = New SqlConnection("Server=localhost;UID=sa;PWD=sa;database=websiteDemo")
dbconn.Open()
dbcommand = New SqlDataAdapter("Select UserID from " _
& "Login Where " _
& "Username = '" & TextBox1.Text _
& "' and Password = '" & TextBox2.Text _
& "'", dbconn)
dbcommand.Fill(dslogin, "Login")
If dslogin.Tables("Login").Rows.Count = 0 Then
Response.Write(dslogin.Tables("Login").Rows.Count = 0)
Label3.Text = "Username and Password Not Found.Please Try Again!"
Else
Session("UserID") = dslogin.Tables("Login").Rows(0).Item("UserID")
Session("Username") = TextBox1.Text
Response.Redirect("./Success.aspx")
End If
End Sub


i m getting : output as:

Username and Password Not Found.Please Try Again!"
instead i have that username in the database. Also i m inputting correct Username and Password.

Last edited by tgreer; Oct 22nd, 2006 at 5:45 pm. Reason: Ignored instructions for CODE tags
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Dhruv Shah is offline Offline
17 posts
since Sep 2006
Oct 23rd, 2006
0

Re: Asp.Net Login Page Problem?

Sorry i m new to ASP.NET so could u explain what is CODE tags.
If it is possible for u can u modify the code i have posted such that it works correctly.
Thanks for Replying me.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Dhruv Shah is offline Offline
17 posts
since Sep 2006
Oct 23rd, 2006
0

Re: Asp.Net Login Page Problem?

The forum software uses code tags for posting code. They are clearly explained in the message editor when you post a message. Just follow the instructions. Also, we use full complete standard English here, instead of the substitutions such as "i"and "u".

I don't code in VB.NET sorry. In any case, ASP.NET Authentication is a well-covered topic with thousands of tutorials on the topic available on the web. Glancing over your code, I see no obvious errors. I tend not to use DataAdapters and DataTables and all that mess. I use stored procedures. You execute them, get the response into a simple DataReader, and do what you need to do.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Nov 5th, 2006
0

Re: Asp.Net Login Page Problem?

Remove dbconn.Open
Reputation Points: 10
Solved Threads: 0
Light Poster
sierrasoft is offline Offline
31 posts
since Nov 2006

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: ASP.NET 2.0 Invalid attempt to FieldCount when reader is closed
Next Thread in ASP.NET Forum Timeline: Need Help:-Reports in ASP.NET1.0





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


Follow us on Twitter


© 2011 DaniWeb® LLC