Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
' Check if username or password is empty
If txtPassword.Text = "" Or txtUsername.Text = "" Then
MessageBox.Show("Please complete the required fields..", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
' Both fields was supply
' Check if user exist in database
' Connect to DB
Dim conn As New System.Data.OleDb.OleDbConnection()
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source = C:\Users\AMD\Desktop\sem 8 2013\fyp\vb\test last\test\fingerprint.accdb"
Try
'conn.Open()
'MsgBox("Susscess")
Dim sql As String = "SELECT * FROM admintable WHERE username='" & txtUsername.Text & "' AND password = '" & txtPassword.Text & "'"
Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql)
'Open Database Connection
sqlCom.Connection = conn
conn.Open()
Dim sqlRead As System.Data.OleDb.OleDbDataReader = sqlCom.ExecuteReader()
If sqlRead.Read() Then
'<retrieve fingerprint attachment from accdb>
Else
' If user enter wrong username and password combination
' Throw an error message
MessageBox.Show("Username and Password do not match..", "Authentication Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
'Clear all fields
txtPassword.Text = ""
txtUsername.Text = ""
'Focus on Username field
txtUsername.Focus()
End If
Catch ex As Exception
MessageBox.Show("Failed to connect to Database..", "Database Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub
这是我开发的编码。在我想要的应用程序中,在用户连续输入正确的用户名和密码后,可以检索存储在accdb中的指纹模板,以便进行验证。
有人可以帮助我,我对visual basic和sql连接的了解有限。
即时通讯使用数字角色设备获取指纹模板,我使用一键式SDK进行验证。
答案 0 :(得分:0)
使用FileStream方法在byte()中读取/存储数据库然后获取文件扩展名以正确地将其存储回它的扩展名中...
答案 1 :(得分:0)
使用FileStream,您应该能够读取和写入您想要的任何文件。这是一个很好的例子,可以帮助您入门。
http://www.codeproject.com/Articles/32216/How-to-store-and-fetch-binary-data-into-a-file-str