Shadez said:simple store the user info in the DB then run a query with the user name and password from the text boxes if it returns results display the main page if not then give them a error message.
marc2003 said:why would you have a confirm password box on a login screen?they're only needed when changing/creating a password to prevent accidentally setting it with a typo in it.
![]()
B&W said:Hi, thanks for the reply. Can you give me some more information on how I would do this.
I guess I would make a new table in the database with 2 fields, user and pwd.
Then I guess I'd have to use some sort of select statement?
noob said:If you only have one username and password don't bother storing it in a DB just use global variables.
http://en.allexperts.com/q/Visual-Basic-1048/vb-net-global-variables.htm
Shadez said:you dont want to store them as globals because you wont be able to change them. Although you could store a single uid and pw in the registry.
Dr_Evil said:
noob said:That applies to ASP.NET, to achieve this in VB.NET is it the same principle?
Imports System.Data.OleDb
Public Class frmUserLogin
Dim mypath = Application.StartupPath & "\Learn 4 Business.mdb"
Dim Password = ""
Private strConn As String = "Provider=Microsoft.Jet.OleDB.4.0;Data Source=E:\L4B\L4B\Learn 4 Business.mdb"
Dim cmd As New OleDb.OleDbCommand
Dim conn As New OleDb.OleDbConnection
Private Sub btncancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncancel.Click
Me.Close()
frmL4B.ShowDialog()
End Sub
Private Sub btnok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnok.Click
Dim conn As OleDbConnection = New OleDbConnection
conn.ConnectionString = strConn
conn.Open()
Dim cmd As OleDbCommand = New OleDbCommand
cmd.CommandText = "SELECT UserName, Password FROM tblPassword WHERE UserName = '" & txtusername.Text & "' AND Password = '" & txtpassword.Text & "'"""
cmd.CommandType = CommandType.Text
cmd.Connection = conn
Dim dr As OleDb.OleDbDataReader = cmd.ExecuteReader
Try
conn.Open()
Catch ex As InvalidOperationException
MsgBox(ex.Message)
End Try
Try
If dr.Read = False Then
MessageBox.Show("Authentication Failed...")
Else
MessageBox.Show("Login Successful...")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
If conn.State <> ConnectionState.Closed Then
conn.Close()
End If
frmMenu.Show()
Me.Close()
End Sub
End Class
Dr_Evil said:You're seriously wasting your time trying to rewrite something that's already there in .Net. You can create the database as .mdf or sql server, either new or existing database. All the components for logging in/out are already there for you to use, you don't need to write this.
I get the following error and it points to the datareader line:
Syntax error in string in query expression 'UserName = 'zahid' AND Password = 'kenya'"'.
Dr_Evil said:Trust me - you don't need to code your own login screens, nor do you need to design your user security tables in your database. This has all been provided for already by the .Net framework.
1. There's a script that will generate all your database tables. It holds an extensive set of info for user and membership security data.
2. .Net has it's own login components. In VS2005 you can drag the Login control onto your page, which provides for entering user credentials and logging the user in. Also you can enable the "Forgotten password" mechanism.
You need to watch the video i posted earlier and have a good read on that site i posted earlier. They will help you understand how to use this stuff.