A Fingerpint Database System...


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: A Fingerpint Database System...

  1. #1
    Join Date
    Mar 2009
    Location
    Malaysia
    Posts
    5

    A Fingerpint Database System...

    Hello,i'm a newbie in this forum..and laso a newbie in programming..i'm not familiar with Vb.NET..

    I'm a student..and making an attendance system using a fingerprint...i'm refer this system to Apress Practical.NET 2.0 Networking Project.It was the chapter 3:Incorporating Fingerprint Recognition into your .NET application.

    I'll already have make it right..but the only problem thati had is..the databse is not stored permanently..the database after been update (scan the fingerprint and stored information)...will vanish after the program is closed adn run again..the database will contain the original and will need to restore..

    i want to ask an answer for this..i hope some of the group member will help me..

  2. #2
    Join Date
    Apr 2008
    Posts
    19
    Can you provide a sample of your code?

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Also, what database are you using and what is the field type you are using for storage?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  4. #4
    Join Date
    Mar 2009
    Location
    Malaysia
    Posts
    5

    I'm using an Access DB...

    This is the coding for my application:

    Imports GrFingerXLib

    Public Class Form1
    '---name of the database---
    Const DBFile = "GrFingerSample.mdb"
    Const Logfile = "C:\Log.csv"
    Const ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="

    '---for an instance of the Util.vb class---
    Private myUtil As Util
    '---for storing userís ID---
    Private _UserID As Integer
    '---database connection string---
    Private connection As System.Data.OleDb.OleDbConnection



    Private Sub Form1_Load( _
    ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles MyBase.Load
    Dim err As Integer
    ' initialize util class
    myUtil = New Util(ListBox1, PictureBox1, AxGrFingerXCtrl1)
    ' Initialize GrFingerX Library
    err = myUtil.InitializeGrFinger()
    ' Print result in log
    If err < 0 Then
    myUtil.WriteError(err)
    Exit Sub
    Else
    myUtil.WriteLog( _
    "**GrFingerX Initialized Successfull**")
    End If

    '---create a log file---
    If Not System.IO.File.Exists(Logfile) Then
    System.IO.File.Create(Logfile)
    End If
    End Sub

    ' -----------------------------------------------------------------------------------
    ' GrFingerX events
    ' -----------------------------------------------------------------------------------
    ' A fingerprint reader was plugged on system
    Private Sub AxGrFingerXCtrl1_SensorPlug( _
    ByVal sender As System.Object, _
    ByVal e As AxGrFingerXLib._IGrFingerXCtrlEvents_SensorPlugEvent) _
    Handles AxGrFingerXCtrl1.SensorPlug
    myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Plugged.")
    AxGrFingerXCtrl1.CapStartCapture(e.idSensor)
    End Sub

    ' A fingerprint reader was unplugged from system
    Private Sub AxGrFingerXCtrl1_SensorUnplug( _
    ByVal sender As System.Object, _
    ByVal e As AxGrFingerXLib._IGrFingerXCtrlEvents_SensorUnplugEvent) _
    Handles AxGrFingerXCtrl1.SensorUnplug
    myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Unplugged.")
    AxGrFingerXCtrl1.CapStopCapture(e.idSensor)
    End Sub

    ' A finger was placed on reader
    Private Sub AxGrFingerXCtrl1_FingerDown( _
    ByVal sender As System.Object, _
    ByVal e As AxGrFingerXLib._IGrFingerXCtrlEvents_FingerDownEvent) _
    Handles AxGrFingerXCtrl1.FingerDown
    myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Finger Placed.")
    End Sub

    ' A finger was removed from reader
    Private Sub AxGrFingerXCtrl1_FingerUp( _
    ByVal sender As System.Object, _
    ByVal e As AxGrFingerXLib._IGrFingerXCtrlEvents_FingerUpEvent) _
    Handles AxGrFingerXCtrl1.FingerUp
    myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Finger removed.")
    End Sub

    ' An image was acquired from reader
    Private Sub AxGrFingerXCtrl1_ImageAcquired( _
    ByVal sender As System.Object, _
    ByVal e As AxGrFingerXLib._IGrFingerXCtrlEvents_ImageAcquiredEvent) _
    Handles AxGrFingerXCtrl1.ImageAcquired

    ' Copying aquired image
    myUtil.raw.height = e.height
    myUtil.raw.width = e.width
    myUtil.raw.res = e.res
    myUtil.raw.img = e.rawImage

    ' Signaling that an Image Event occurred.
    myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Image captured.")

    ' display fingerprint image
    myUtil.PrintBiometricDisplay(False, GRConstants.GR_DEFAULT_CONTEXT)

    '---extract the template from the fingerprint scanned---
    ExtractTemplate()

    '---identify who the user is---
    _UserID = IdentifyFingerprint()
    If _UserID > 0 Then
    '---user found---
    Beep()
    btnRegister.Enabled = False
    '---display user's information---
    GetUserInfo()
    '---writes to log file---
    WriteToLog(_UserID)
    Else
    '---user not found---
    ClearDisplay()
    btnRegister.Enabled = True
    Beep()
    lblMessage.Text = "User not found! Please register your information below"
    End If
    End Sub

    ' Extract a template from a fingerprint image
    Private Function ExtractTemplate() As Integer
    Dim ret As Integer
    ' extract template
    ret = myUtil.ExtractTemplate()
    ' write template quality to log
    If ret = GRConstants.GR_BAD_QUALITY Then
    myUtil.WriteLog("Template extracted successfully. Bad quality.")
    ElseIf ret = GRConstants.GR_MEDIUM_QUALITY Then
    myUtil.WriteLog("Template extracted successfully. Medium quality.")
    ElseIf ret = GRConstants.GR_HIGH_QUALITY Then
    myUtil.WriteLog("Template extracted successfully. High quality.")
    End If
    If ret >= 0 Then
    ' if no error, display minutiae/segments/directions into the image
    myUtil.PrintBiometricDisplay(True, GRConstants.GR_NO_CONTEXT)
    Else
    ' write error to log
    myUtil.WriteError(ret)
    End If
    Return ret
    End Function


    '---Identify a fingerprint; returns the ID of the user---
    Private Function IdentifyFingerprint() As Integer
    Dim ret As Integer, score As Integer
    score = 0
    ' identify it
    ret = myUtil.Identify(score)
    ' write result to log
    If ret > 0 Then
    myUtil.WriteLog("Fingerprint identified. ID = " & ret & ". Score = " & score & ".")
    myUtil.PrintBiometricDisplay(True, GRConstants.GR_DEFAULT_CONTEXT)
    ElseIf ret = 0 Then
    myUtil.WriteLog("Fingerprint not Found.")
    Else
    myUtil.WriteError(ret)
    End If
    Return ret
    End Function

    '---get user's information---
    Public Sub GetUserInfo()
    Dim filePath As String
    Try
    filePath = Application.StartupPath() & "\" & DBFile
    connection = New OleDb.OleDbConnection(ConnectionString & filePath)
    connection.Open()
    Dim reader As OleDb.OleDbDataReader
    Dim command As OleDb.OleDbCommand = New OleDb.OleDbCommand
    command.Connection = connection
    '---retrieve user's particulars---
    command.CommandText = "SELECT * FROM Enroll WHERE ID=" & _UserID
    reader = command.ExecuteReader(CommandBehavior.CloseConnection)
    reader.Read()

    '---display user's particulars---
    lblMessage.Text = "Welcome, " & reader("name")
    txtName.Text = reader("Name")
    txtICNumber.Text = reader("IC Number")
    txtMatrixNumber.Text = reader("Matrix Number")
    txtFaculty.Text = reader("Faculty")
    txtYear.Text = reader("Year")
    txtCourse.Text = reader("Course")
    txtContact.Text = reader("Contact")

    '---reset the timer to another 5 seconds---
    Timer1.Enabled = False
    Timer1.Enabled = True
    Catch ex As Exception
    MsgBox(ex.ToString)
    Finally
    connection.Close()
    End Try
    End Sub

    *continue....

  5. #5
    Join Date
    Mar 2009
    Location
    Malaysia
    Posts
    5

    Continue...

    The continue of the coding...

    '---Register button---
    Private Sub btnRegister_Click( _
    ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles btnRegister.Click
    '---first add the fingerprint---
    _UserID = EnrollFingerprint()
    '---then add the particulars---
    AddNewUser()
    '---clears the display---
    ClearDisplay()
    '---writes to log file---
    WriteToLog(_UserID)
    End Sub

    '---adds a fingerprint to the database; returns the ID of the user---
    Private Function EnrollFingerprint() As Integer
    Dim id As Integer
    ' add fingerprint
    id = myUtil.Enroll()
    ' write result to log
    If id >= 0 Then
    myUtil.WriteLog("Fingerprint enrolled with id = " & id)
    Else
    myUtil.WriteLog("Error: Fingerprint not enrolled")
    End If
    Return id
    End Function

    '---Add a new user's information to the database---
    Public Sub AddNewUser()
    Dim filePath As String
    Try
    filePath = Application.StartupPath() & "\" & DBFile
    connection = New OleDb.OleDbConnection(ConnectionString & filePath)
    connection.Open()
    Dim command As OleDb.OleDbCommand = New OleDb.OleDbCommand
    command.Connection = connection

    '---set the user's particulars in the table---
    Dim sql As String = "UPDATE enroll Name='" & txtName.Text & "', " & _
    "MatrixNumber='" & txtMatrixNumber.Text & "', " & _
    "ICNumber='" & txtICNumber.Text & "', " & _
    "Faculty='" & txtFaculty.Text & "', " & _
    "Year='" & txtYear.Text & "' " & _
    "Course='" & txtCourse.Text & "' " & _
    "contact='" & txtContact.Text & "' " & _
    " WHERE ID=" & _UserID
    command.CommandText = sql
    command.ExecuteNonQuery()
    MsgBox("User added successfully!")
    connection.Close()
    Catch ex As Exception
    MsgBox(ex.ToString)
    End Try
    End Sub

    '---Clears the user's particulars---
    Public Sub ClearDisplay()
    lblMessage.Text = _
    "Please place your index finger on the fingerprint reader"
    PictureBox1.Image = My.Resources.fingerprintreader

    txtName.Text = String.Empty
    txtICNumber.Text = String.Empty
    txtMatrixNumber.Text = String.Empty
    txtFaculty.Text = String.Empty
    txtYear.Text = String.Empty
    txtCourse.Text = String.Empty
    txtContact.Text = String.Empty
    End Sub

    '---the Timer control---
    Private Sub Timer1_Tick( _
    ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles Timer1.Tick
    ClearDisplay()
    Timer1.Enabled = False
    End Sub

    Public Sub WriteToLog(ByVal ID As String)
    '---write to a log file---
    Dim sw As New System.IO.StreamWriter( _
    Logfile, True, System.Text.Encoding.ASCII)
    sw.WriteLine(id & "," & Now.ToString)
    sw.Close()
    End Sub

    End Sub
    End Class

    There is other resource that is used in this system its a DB.vb for the storage option and the Util.vb that react as utilization of hardware that i'm using which is Microsoft Fingerprint Reader...

    I really cannot understand that very much..but from a comment i know somthing about the program..but the only problem is when to recall the data from database..it's obviously cannot stored data permanently..always work when first running..then after been stop and run again..seem the data start from beginning...no informaation of data that already stored...

  6. #6
    Join Date
    Mar 2009
    Location
    Malaysia
    Posts
    5

    This is DB.vb that being used...

    This file already been provided and i'm not so sure about the coding..how it would effect...i'm added it as reource based from that books..



    -----------------------------------------------------------------------------------
    ' Database routines
    ' -----------------------------------------------------------------------------------

    Imports System.Data.OleDb
    Imports System.Runtime.InteropServices

    ' Template data
    Public Class TTemplate
    ' Template itself
    Public tpt As System.Array = Array.CreateInstance(GetType(Byte), GrFingerXLib.GRConstants.GR_MAX_SIZE_TEMPLATE)


    ' Template size
    Public Size As Long
    End Class

    ' Template list
    Public Structure TTemplates
    ' ID
    Public ID As Integer
    ' Template itself
    Public template As TTemplate
    End Structure

    Public Class DBClass

    ' the database we'll be connecting to
    Const DBFile As String = "../../../GrFingerSample.mdb"
    Const ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="

    ' the connection object
    Dim connection As New OleDbConnection

    ' Open connection
    Public Function OpenDB() As Boolean
    Dim filePath As String
    Try
    filePath = Application.StartupPath() & "\" & DBFile
    connection = New OleDb.OleDbConnection(ConnectionString & filePath)
    Return True
    Catch
    Return False
    End Try
    End Function

    ' Close conection
    Public Sub closeDB()
    connection.Close()
    End Sub

    ' Clear database
    Public Sub clearDB()
    Dim sqlCMD As OleDbCommand = New OleDbCommand("DELETE FROM enroll", connection)
    ' run "clear" query
    sqlCMD.Connection.Open()
    sqlCMD.ExecuteNonQuery()
    sqlCMD.Connection.Close()
    End Sub

    ' Add template to database. Returns added template ID.
    Public Function AddTemplate(ByRef template As TTemplate) As Long
    Dim da As New OleDbDataAdapter("select * from enroll", connection)

    ' Create SQL command containing ? parameter for BLOB.
    da.InsertCommand = New OleDbCommand("INSERT INTO enroll (template) Values(?)", connection)
    da.InsertCommand.CommandType = CommandType.Text
    da.InsertCommand.Parameters.Add("@template", OleDbType.Binary, template.Size, "template")

    ' Open connection
    connection.Open()

    ' Fill DataSet.
    Dim enroll As DataSet = New DataSet
    da.Fill(enroll, "enroll")

    ' Add a new row.
    ' Create parameter for ? contained in the SQL statement.
    Dim newRow As DataRow = enroll.Tables("enroll").NewRow()
    newRow("template") = template.tpt
    enroll.Tables("enroll").Rows.Add(newRow)

    ' Include an event to fill in the Autonumber value.
    AddHandler da.RowUpdated, New OleDbRowUpdatedEventHandler(AddressOf OnRowUpdated)

    ' Update DataSet.
    da.Update(enroll, "enroll")
    connection.Close()

    ' return ID
    Return newRow("ID")
    End Function

    ' Event procedure for OnRowUpdated
    Private Sub OnRowUpdated(ByVal sender As Object, ByVal args As OleDbRowUpdatedEventArgs)
    ' Include a variable and a command to retrieve identity value
    ' from Access database.
    Dim newID As Integer = 0
    Dim idCMD As OleDbCommand = New OleDbCommand("SELECT @@IDENTITY", connection)

    If args.StatementType = StatementType.Insert Then
    ' Retrieve identity value and store it in column
    newID = CInt(idCMD.ExecuteScalar())
    args.Row("ID") = newID
    End If
    End Sub

    ' Returns a DataTable with all enrolled templates from database.
    Public Function getTemplates() As TTemplates()
    Dim ds As New DataSet
    Dim da As New OleDbDataAdapter("select * from enroll", connection)
    Dim ttpts As TTemplates()
    Dim i As Integer

    ' Get query response
    da.Fill(ds)
    Dim tpts As DataRowCollection = ds.Tables(0).Rows
    ' Create response array
    ReDim ttpts(tpts.Count)
    ' No results?
    If tpts.Count = 0 Then Return ttpts
    ' get each template and put results in our array
    For i = 1 To tpts.Count
    ttpts(i).template = New TTemplate
    ttpts(i).ID = tpts.Item(i - 1).Item("ID")
    ttpts(i).template.tpt = tpts.Item(i - 1).Item("template")
    ttpts(i).template.Size = ttpts(i).template.tpt.Length
    Next
    Return ttpts
    End Function

    ' Returns template with supplied ID.
    Public Function getTemplate(ByVal id As Long) As Byte()
    Dim ds As New DataSet
    Dim da As New OleDbDataAdapter("select * from enroll where ID = " & id, connection)
    Dim tpt As New TTemplate

    ' Get query response
    da.Fill(ds)
    Dim tpts As DataRowCollection = ds.Tables(0).Rows
    ' No results?
    If tpts.Count <> 1 Then Return Nothing
    ' Deserialize template and return it
    Return tpts.Item(0).Item("template")
    End Function

    End Class

  7. #7
    Join Date
    Apr 2008
    Posts
    19
    First, you should use the code tags. (select all your lines of code and click the '#' button) You can go back to your previous posts and edit them.


    Is this the method your using to edit your database?
    Code:
    '---Add a new user's information to the database---
    Public Sub AddNewUser()
    Dim filePath As String
    Try
    filePath = Application.StartupPath() & "\" & DBFile
    connection = New OleDb.OleDbConnection(ConnectionString & filePath)
    connection.Open()
    Dim command As OleDb.OleDbCommand = New OleDb.OleDbCommand
    command.Connection = connection
    
    '---set the user's particulars in the table---
    Dim sql As String = "UPDATE enroll Name='" & txtName.Text & "', " & _
    "MatrixNumber='" & txtMatrixNumber.Text & "', " & _
    "ICNumber='" & txtICNumber.Text & "', " & _
    "Faculty='" & txtFaculty.Text & "', " & _
    "Year='" & txtYear.Text & "' " & _
    "Course='" & txtCourse.Text & "' " & _
    "contact='" & txtContact.Text & "' " & _
    " WHERE ID=" & _UserID
    command.CommandText = sql
    command.ExecuteNonQuery()
    MsgBox("User added successfully!")
    connection.Close()
    Catch ex As Exception
    MsgBox(ex.ToString)
    End Try
    End Sub
    I thought this was what you were using, but now that I'm looking at it again, it doesn't look like it would work. The sql string is missing parts (commas and 'Set'). I think, that if you tried using it, the message box would display an error and not 'User added successfully'.

    Where is the code you are using to change your database? Are you using the DBClass object, that's in your last post?
    Last edited by jpj162; 03-23-2009 at 12:39 AM.

  8. #8
    Join Date
    Mar 2009
    Location
    Malaysia
    Posts
    5

    how this coding stored information...

    i already fixed the missng SET and commas..i carely miss it and after refer for the exmaple..i finnly manage to make the porgram work...without error...

    but...i still searching wchich is the coding that refer the function of storing information data in database...because i still cannot manage to sotre the iformtion and reatain the information in database..make it always updated...

    i found this Devx.com also has provied this article...this is a link of the system that i want to build...

    http://www.devx.com/security/Article/31576

    this article has provide the exmaple code thatv i'm refer to...

    hope you can give me some idea...what is needed to be studied to solve this problem...

  9. #9
    Join Date
    Apr 2008
    Posts
    19
    What changes are you trying to make to your database that you are not seeing? Are you trying to add records or change records?

    Your method 'AddNewUser()' is not written to add new records to your database. I haven't looked to hard at your code, so maybe you are adding a blank record somewhere else then adding the information (updating the record) here. If this is not the case your sql should start with 'INSERT INTO' and there should be no 'WHERE'. Here's an example of it: http://www.w3schools.com/sql/sql_insert.asp
    Last edited by jpj162; 03-23-2009 at 05:51 PM.

Similar Threads

  1. Access Database, using VB as front end
    By binnymann in forum Database
    Replies: 3
    Last Post: 04-13-2008, 02:23 AM
  2. Database System Question
    By Augury in forum Database
    Replies: 9
    Last Post: 04-11-2008, 12:09 PM
  3. XML files vs Database
    By Mansoor in forum Enterprise
    Replies: 2
    Last Post: 09-10-2002, 11:38 PM
  4. How to analyze corrupted Access databases
    By Raffaele in forum VB Classic
    Replies: 15
    Last Post: 06-27-2001, 10:28 AM
  5. Replies: 1
    Last Post: 06-27-2000, 08:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center