Re: Using Access Database as Membership source



On Apr 26, 12:08 am, James <J...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
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

James, your code is working for me.
Can you post here the complete error message?

.



Relevant Pages

  • Re: Incompatibility between Access 2003 and Access 2002
    ... Private WithEvents mlst As ListBox ... Private mot As ObjectType ... Public DisplayField As String ... Dim prm As DAO.Parameter ...
    (microsoft.public.access.modulesdaovba)
  • Re: FileSystemWatcher advice required please
    ... Private ArchiveImport As String ... Private FilesToProcess As ProcessFiles ... Public Sub Main ... Dim NoVersion As New Collection ...
    (microsoft.public.dotnet.framework)
  • Re: Is there a way to prevent a RichTextBox from scrolling?
    ... Private _isRegex As Boolean ... Public Sub New(ByVal thispattern As String, ... Dim entry As tDict ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • MAPI Emails from Access
    ... I realize this code is quite long, but could someone take a look at the sub ... Private Const mcERR_DOH = vbObjectError + 10000 ... Private mstStatus As String ... Dim db As Database, rs As Recordset ...
    (microsoft.public.access.formscoding)
  • Re: File attributes
    ... Private Declare Function GetFullPathName Lib "kernel32" Alias ... ByVal lpFileName As String, _ ... Dim Buffer As String ... Private Const VOS_UNKNOWN = &H0 ...
    (microsoft.public.excel.programming)