數據庫我下載的報名示例代碼爲我的設備的DigitalPersona使用。它可能已經註冊並驗證指紋,但問題是它將指紋.fpt文件保存在文件夾中。我想將它保存在數據庫中。
如何直接保存的指紋在使用SDK的DigitalPersona
這是我已經到目前爲止已經試過。
private void SaveButton_Click(object sender, EventArgs e)
{
SaveFileDialog save = new SaveFileDialog();
save.Filter = "Fingerprint Template File (*.fpt)|*.fpt";
if (save.ShowDialog() == DialogResult.OK)
using (FileStream fs = File.Open(save.FileName, FileMode.Create, FileAccess.Write))
{
Template.Serialize(fs);
fs.Close();
//Read the file and convert it to byte array
string filePath = save.FileName;
string filename = Path.GetFileName(filePath);
FileStream fst = new FileStream(filePath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fst);
Byte[] bytes = br.ReadBytes((Int32)fst.Length);
br.Close();
fst.Close();
//Insert the file into database
SqlConnection cn = new SqlConnection("Data Source=10.115.5.3; Initial Catalog=EnrollmentSampledb;Integrated Security=SSPI;");
SqlCommand cmd = new SqlCommand("INSERT INTO tblUser VALUES(@ID_NUMBER, @FIRSTNAME, @LASTNAME, @FINGERPRINT, @DATE_ADDED, @DATE_MODIFIED)", cn);
cmd.Parameters.Add("ID_NUMBER", SqlDbType.NVarChar).Value = tboxIdNum.Text;
cmd.Parameters.Add("FIRSTNAME", SqlDbType.NVarChar).Value = tboxFname.Text;
cmd.Parameters.Add("LASTNAME", SqlDbType.NVarChar).Value = tboxLname.Text;
cmd.Parameters.Add("FINGERPRINT", SqlDbType.Image).Value = bytes;
cmd.Parameters.Add("DATE_ADDED", SqlDbType.DateTime).Value = DateTime.Now;
cmd.Parameters.Add("DATE_MODIFIED", SqlDbType.DateTime).Value = DateTime.Now;
cn.Open(); cmd.ExecuteNonQuery();
cn.Close();
}
tboxIdNum.Text = "";
tboxFname.Text = "";
tboxLname.Text = "";
}
這一個在數據庫中保存的指紋文件,但它首先需要將其保存的文件夾。我想直接將它保存在數據庫中,但我有點困惑如何做到這一點。我找不到要保存的文件。 T_T我很抱歉有點小白菜。有沒有人以前做過這個?
什麼不能在此代碼的工作?異常在哪裏? – Smartis
沒有這個代碼的作品。唯一的問題是它需要首先將指紋保存在文件夾中,然後從該文件夾中檢索它並轉換爲字節並將其保存到數據庫中。有沒有其他解決方法直接將其保存到數據庫? :( – bot
我知道我只是需要一點點扭曲,因爲我已經可以將它保存在數據庫中。 – bot