Private Sub ScanerCtrl1_OnEnrollSuccess(ByVal sender As System.Object, ByVal e As AxWACFPSCANER.__ScanerCtrl_OnEnrollSuccessEvent) Handles ScanerCtrl1.OnEnrollSuccess
'e.quality is quality of fingerprint ( 1 - 10 )
'1 is Worst
'10 is Excellent
LbMessage.Text = "Enroll success quality is " & e.quality.ToString() & " (" & CInt(e.quality) & ")"
'Prepare byte array to storage fingerprint
Dim EnrollData() As Byte
'Get Enroll fingerprint from memory
If ScanerCtrl1.GetEnrollData(EnrollData) = 0 Then
Dim f As New frmAddName
Dim retName As String
retName = f.GetUserName()
If retName = "" Then
MsgBox("User name can't be null, please enroll again")
Exit Sub
End If
On Error Resume Next
conn = New MySqlConnection(connStr)
conn.Open()
sql = "Insert into user(uid, uname) values(NULL,'" & retName & "')"
Dim cmd As MySqlCommand = New MySqlCommand(sql, conn)
cmd.ExecuteNonQuery()
conn.Close()
conn.Dispose()
Dim dates As String = Year(Today) & "/" & Now.ToString("mm/dd HH:MM:ss")
sql = "Insert into fingerprint(fid, uname, ftemplate, fmodify) values(NULL, '" & retName & "', " & EnrollData & " , '" & dates & "')"
'error ตรงนี้ด้วยนะครับมันแจ้งว่า Operator & is not defined for type 'String' and 1-dimensional array of byte
cmd = New MySqlCommand(sql, conn)
cmd.ExecuteNonQuery()
conn.Close()
conn.Dispose()
'===========================================================================================
FingerprintImage1.Clear()
End If
End Sub
Imports System.Data
Imports MySql.Data.MySqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
Me.pnlForm.Visible = False
If Me.fUpload.HasFile = False Or Me.txtName.Text = "" Then
Me.lblStatus.Text = "Please input Name and Chooes File."
Else
'*** Read Binary Data ***'
Dim imbByte(fUpload.PostedFile.InputStream.Length) As Byte
fUpload.PostedFile.InputStream.Read(imbByte, 0, imbByte.Length)
'*** MimeType ***'
Dim ExtType As String = System.IO.Path.GetExtension(fUpload.PostedFile.FileName).ToLower()
Dim strMIME As String = Nothing
Select Case ExtType
Case ".gif"
strMIME = "image/gif"
Case ".jpg", ".jpeg", ".jpe"
strMIME = "image/jpeg"
Case ".png"
strMIME = "image/png"
Case Else
Me.lblStatus.Text = "Invalid file type."
Exit Sub
End Select
'*** Insert to Database ***'
Dim objConn As New MySqlConnection
Dim strConnString, strSQL As String
strConnString = "Server=localhost;User Id=root; Password=root; Database=mydatabase; Pooling=false;"
strSQL = "INSERT INTO files (Name,FilesName,FilesType) " & _
" VALUES " & _
" (?sName,?sFilesName,?sFilesType)"
objConn.ConnectionString = strConnString
objConn.Open()
Dim objCmd As New MySqlCommand(strSQL, objConn)
objCmd.Parameters.Add("?sName", MySqlDbType.VarChar).Value = Me.txtName.Text
objCmd.Parameters.Add("?sFilesName", MySqlDbType.Binary).Value = imbByte
objCmd.Parameters.Add("?sFilesType", MySqlDbType.VarChar).Value = strMIME
objCmd.ExecuteNonQuery()
objConn.Close()
objConn = Nothing
Me.lblStatus.Text = "File Upload Successfully. Click <a href='ListPicture.aspx'>here</a> to view."
End If
End Sub
End Class