Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 1.0
This is the forum to discuss the Wrox book Beginning ASP.NET 1.0 with C# by Chris Goode, John Kauffman, Christopher L. Miller, Neil Raybould, S. Srinivasa Sivakumar, Dave Sussman, Ollie Cornes, Rob Birdwell, Matt Butler, Gary Johnson, Ajoy Krishnamoorthy, Juan T. Llibre, Chris Ullman; ISBN: 9780764543708
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 15th, 2004, 07:09 PM
Authorized User
 
Join Date: Jul 2004
Location: St. John\'s, NL, Canada.
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default Login Form ASP.NET

Hello All,

First of all I am new to .NET. I am trying to create a login (login2.aspx) form that checks an Access database table (called user) to see if the user is a valid user or not. I have seen examples, but they hard code the user/password into the page or they only check one field. I need to check both fields (username and password).

Please any help is greatly appreciated,

Thanks in Advance,
Mark.


  #2 (permalink)  
Old July 17th, 2004, 12:30 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Where do u want to check ur user & Password from?! do u use any DB?!

Always:),
Hovik Melkomian.
  #3 (permalink)  
Old July 18th, 2004, 10:02 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Assuming you brought back the results to a data table:

Dim strSQL As String = select * from Users where username = '" & txtUserName.Text & "' and password = '" & txtPassword.Text & "'"
'.. load the data to a dataset or datatable, not shown here ..

if (objTable.Rows.Count > 0 ) then
  'User exists
else
  'User doesn't exist with a valid user id or password
end if

If you want to display a separate message for user id/password problems, then you need to bring the results back based on user ID, and then check the password (if (objtable.rows(0).Item("Password") = strPassword)) in your code.

Brian
  #4 (permalink)  
Old July 19th, 2004, 08:56 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,111
Thanks: 0
Thanked 3 Times in 3 Posts
Default

    Function DBAuthenticate(ByVal strUsername As String, ByVal strPassword As String) As Integer
        Dim bResult As Boolean = False
        Dim objConn As New OleDbConnection(ConfigurationSettings.AppSettings( "myDB"))
        Dim strSQL As String
        Dim strGoodPassword As String
        Dim objCommand As New OleDbCommand

        objCommand.Connection = objConn
        strSQL = String.Format("SELECT p_w FROM myDB WHERE (email='{0}');", strUsername)
        objCommand.CommandText = strSQL
        objCommand.CommandType = CommandType.Text

        objConn.Open()
        strGoodPassword = CType(objCommand.ExecuteScalar, String)
        objConn.Close()

        If Not strGoodPassword Is Nothing Then
            If strGoodPassword = strPassword Then
                bResult = True
            Else
                lblMessage.Text = "Invalid Login!"
                lblMessage.Text &= " If you are not a member please click the above link to register."
            End If
        Else
            lblMessage.Text = "Invalid Login!"
            lblMessage.Text &= " If you are not a member please click the above link to register."
        End If

        Return bResult
    End Function

This function takes the username and password passed to it from the "Button1_Click" Sub and checks to see if they are valid. (written by PLanoie)

  #5 (permalink)  
Old July 19th, 2004, 11:36 AM
Authorized User
 
Join Date: Jul 2004
Location: St. John\'s, NL, Canada.
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks to all that replied. I have it working. and works great.

Thanks again.
Mark

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
asp.net login control kulkarnimonica ASP.NET 2.0 Professional 6 September 25th, 2007 05:22 PM
ASp.net 2.0 login name control kulkarnimonica ASP.NET 2.0 Professional 12 July 11th, 2007 12:42 AM
Windows Login via ASP.net rwalker VS.NET 2002/2003 9 June 20th, 2007 03:27 PM
ASP.net login page in C# in 2.0 debjanib ASP.NET 2.0 Basics 4 March 23rd, 2007 08:46 AM
how to create login page using asp.net prakashbabu ASP.NET 2.0 Basics 1 March 7th, 2007 11:52 AM



All times are GMT -4. The time now is 06:20 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.