J
James
Hi
I am quite new to membership and security etc. I have a large Access DB and
want to create a special section on a website for some of the members in the
database.
I have looked how to do this and have found about 10 sites, all with
different ways to do this. I have tried all but none work. The code I have
got closest to working is:
Web.Config:
<system.web>
<authentication mode="Forms"/>
<membership
defaultProvider="AccessMembershipProvider" >
<providers>
<add name="AccessMembershipProvider"
type="AccessMembershipProvider"
requiresQuestionAndAnswer="true"
connectionString="Provider=Microsoft.Jet.
OLEDB.4.0;Data Source=C:\NewMembershipProvider\
App_Data\Members.mdb;Persist Security
Info=False" />
</providers>
</membership>
</system.web>
AccessMembershipProvider.vb:
Private connStr As String
Private comm As New OleDb.OleDbCommand
Private _requiresQuestionAndAnswer As Boolean
Private _minRequiredPasswordLength As Integer
Public Overrides Function ValidateUser( _
ByVal username As String, _
ByVal password As String) As Boolean
Dim conn As New OleDb.OleDbConnection(connStr)
Try
conn.Open()
Dim sql As String = _
"Select * From Membership WHERE " & _
"username=@username AND password=@password"
Dim comm As New OleDb.OleDbCommand(sql, conn)
comm.Parameters.AddWithValue("@username", _
username)
comm.Parameters.AddWithValue("@password", _
password)
Dim reader As OleDb.OleDbDataReader = _
comm.ExecuteReader
If reader.HasRows Then
Return True
Else
Return False
End If
conn.Close()
Catch ex As Exception
Console.Write(ex.ToString)
Return False
End Try
End Function
That code comes up with errors about the OleDb.OleDbCommand saying I should
put Data. infront of it.
Is there anyone who can point me in the right direction on how to do this?
Many thanks
James
I am quite new to membership and security etc. I have a large Access DB and
want to create a special section on a website for some of the members in the
database.
I have looked how to do this and have found about 10 sites, all with
different ways to do this. I have tried all but none work. The code I have
got closest to working is:
Web.Config:
<system.web>
<authentication mode="Forms"/>
<membership
defaultProvider="AccessMembershipProvider" >
<providers>
<add name="AccessMembershipProvider"
type="AccessMembershipProvider"
requiresQuestionAndAnswer="true"
connectionString="Provider=Microsoft.Jet.
OLEDB.4.0;Data Source=C:\NewMembershipProvider\
App_Data\Members.mdb;Persist Security
Info=False" />
</providers>
</membership>
</system.web>
AccessMembershipProvider.vb:
Private connStr As String
Private comm As New OleDb.OleDbCommand
Private _requiresQuestionAndAnswer As Boolean
Private _minRequiredPasswordLength As Integer
Public Overrides Function ValidateUser( _
ByVal username As String, _
ByVal password As String) As Boolean
Dim conn As New OleDb.OleDbConnection(connStr)
Try
conn.Open()
Dim sql As String = _
"Select * From Membership WHERE " & _
"username=@username AND password=@password"
Dim comm As New OleDb.OleDbCommand(sql, conn)
comm.Parameters.AddWithValue("@username", _
username)
comm.Parameters.AddWithValue("@password", _
password)
Dim reader As OleDb.OleDbDataReader = _
comm.ExecuteReader
If reader.HasRows Then
Return True
Else
Return False
End If
conn.Close()
Catch ex As Exception
Console.Write(ex.ToString)
Return False
End Try
End Function
That code comes up with errors about the OleDb.OleDbCommand saying I should
put Data. infront of it.
Is there anyone who can point me in the right direction on how to do this?
Many thanks
James