|
| username & password validation |
 |
Sun, 23 Mar 2008 00:06:30 +000 |
I am trying to validate a username and password that has been entered in a text
box, and validating it against a username and password that is in an Access
database. How would I do that in visual web developer using sql?
|
| Post Reply
|
| Re: username & password validation |
 |
Sun, 23 Mar 2008 08:40:23 +000 |
In the onclick of the logon button, try something like (I'm using VB.NET):
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=|DataDirectory|userdatabase.mdb"
Dim cn As New OleDbConnection(strConn)
Try
cn.Open()
Dim cm As New OleDbCommand("SELECT COUNT(*) FROM users WHERE
username=? AND password=?;", cn)
cm.Parameters.AddWithValue("?",TextBoxUsername.Text)
cm.Parameters.AddWithValue("?",TextBoxPassword.Text)
Dim count As Integer = CInt(cm.ExecuteScalar())
If(count>0) Then
' user successfully logged on
' do something
Else
lblError.Text = "Logon failed"
End If
Catch ex As Exception
lblError.Text = ex.Message()
Finally
cn.Close()
End Try
Jos
|
| Post Reply
|
| Re: username & password validation |
 |
Sat, 29 Mar 2008 15:45:39 +000 |
can you give the same exemple in c# code?
|
| Post Reply
|
| Re: username & password validation |
 |
Sun, 30 Mar 2008 10:44:57 +000 |
Automatic translation from vb to C#:
http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx
Jos
|
| Post Reply
|
| Re: username & password validation |
 |
Mon, 31 Mar 2008 13:45:24 +000 |
create procedure CheckLoginDetails
(
@username nvarchar(100),
@password nvarchar(100)
)
As
Begin
select Count(*) from tablename where Username=@username ,password=@password
End
in Codebehind Ur using Executescalar.
|
| Post Reply
|
|
|
|
|
|
|
|
|
|