|
|
|
c# ผมอยากเก็บ byte[] ในmy sql พร้อม select ดูอะครับ ควรแก้ไข้โคร๊สยังไงครับช่วยที ใช้ type ประเภทไหนคับ |
|
|
|
|
|
|
|
Code (C#)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Simple_Code
{
public partial class UserControl1 : UserControl
{
DataSet dsl_select;
public string[] Value = new string[6];
bool isConnected;
int FMatchType;
int fpcHandle;
int time = 0;
int i = 3;
bool VerifyCheck = false;
object VerTemplate;
object RegTemplate;
string RegTemplateStr;
string izkfpver;
string test;
public event PropertyChangedEventHandler property;
public delegate void PropertyChangedEventHandler(string s);
public UserControl1()
{
InitializeComponent();
}
public string[] Connection()
{
axZKFPEngX1.FPEngineVersion = "9";
izkfpver = axZKFPEngX1.FPEngineVersion;
axZKFPEngX1.SensorIndex = 0;
if (axZKFPEngX1.InitEngine() == 0)
{
try
{
Value[0] = "Connect";
Value[1] = "Finger Serial Number :" + axZKFPEngX1.SensorSN.ToString();
Value[2] = "Finger Count :" + axZKFPEngX1.SensorCount.ToString();
Value[3] = "Finger Index :" + axZKFPEngX1.SensorIndex.ToString();
Value[4] = "ImageWidth Record :" + axZKFPEngX1.ImageWidth.ToString();
Value[5] = "ImageHeight Record :" + axZKFPEngX1.ImageHeight.ToString();
isConnected = true;
fpcHandle = axZKFPEngX1.CreateFPCacheDB();
}
catch
{
axZKFPEngX1.EndEngine();
Value[0] = "Disconnect";
Value[1] = "";
Value[2] = "";
Value[3] = "";
Value[4] = "";
Value[5] = "";
isConnected = false;
}
}
return Value;
}
public void Disconnect()
{
axZKFPEngX1.EndEngine();
//GlobalValue.FingerValue = null;
isConnected = false;
}
public void BeginEnroll()
{
if (isConnected == true)
{
if (axZKFPEngX1.IsRegister)
{
axZKFPEngX1.CancelEnroll();
}
axZKFPEngX1.EnrollCount = 3;
axZKFPEngX1.BeginEnroll();
property("Begin Enroll");
}
else
{
property("No Sensor Connected");
}
}
private void axZKFPEngX1_OnFingerTouching(object sender, EventArgs e)
{
property("FingerTouching");
}
private void axZKFPEngX1_OnFingerLeaving(object sender, EventArgs e)
{
property("OnFingerLeaving");
}
private void axZKFPEngX1_OnEnroll(object sender, AxZKFPEngXControl.IZKFPEngXEvents_OnEnrollEvent e)
{
byte[] tmp = new byte[0];
if (e.actionResult)
{
//MessageBox.Show(e.aTemplate.ToString());
tmp = (byte[])e.aTemplate;
//GlobalValue.FingerValue = tmp;
}
else
{
tmp = null;
//GlobalValue.FingerValue = tmp;
}
System.Data.SqlClient.SqlConnection con;
con = new System.Data.SqlClient.SqlConnection();
con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|Database.mdf;Integrated Security=True;User Instance=True";
**** string sql = "UPDATE Finger_Table SET Finger_Value=@Finger_Value WHERE User_ID= "+GlobalValue.Index+"";
SqlCommand cmd = new SqlCommand(sql, con);
con.Open();
SqlParameter parafinger = new SqlParameter();
parafinger.ParameterName = "@Finger_Value";
parafinger.Value = tmp;
cmd.Parameters.Add(parafinger);
cmd.ExecuteNonQuery();
property("OnEnroll");
}
public void BeginVerify()
{
if (!isConnected)
{
MessageBox.Show("Please Initial sensor first!", "notice");
return;
}
if (axZKFPEngX1.IsRegister)
{
axZKFPEngX1.CancelEnroll();
}
VerifyCheck = true;
axZKFPEngX1.BeginCapture();
property("OnVerify");
}
private void axZKFPEngX1_OnCapture(object sender, AxZKFPEngXControl.IZKFPEngXEvents_OnCaptureEvent e)
{
//string tmpbyte;
VerTemplate = e.aTemplate;
byte[] vartemplat = (byte[])VerTemplate;
//int score = 9;
//int processedFPNumber = 1;
//int ID;
//string tempstr;
string Template = axZKFPEngX1.GetTemplateAsString();
if (e.actionResult && VerifyCheck == true)
{
VerifyCheck = false;
bool check = false;
string temp;
axZKFPEngX1.OneToOneThreshold = 40;
axZKFPEngX1.Threshold = 40;
temp = axZKFPEngX1.GetTemplateAsString();
System.Data.SqlClient.SqlConnection con;
con = new System.Data.SqlClient.SqlConnection();
dsl_select = new DataSet();
//try
//{
con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|Database.mdf;Integrated Security=True;User Instance=True";
**** string sql = "SELECT Finger_Value FROM Finger_Table WHERE User_ID = '"+GlobalValue.Index+"'";
SqlDataAdapter da = new SqlDataAdapter(sql, con);
con.Open();
da.Fill(dsl_select, "SELECT");
DataRow dRow = dsl_select.Tables["SELECT"].Rows[0];
//tmpbyte = dRow.ItemArray.GetValue(0);
object fingerTemp = dRow.ItemArray.GetValue(0);
if (axZKFPEngX1.VerFinger(ref fingerTemp, VerTemplate, false, ref check) == true)
{
MessageBox.Show("Sucess!!");
}
else
{
MessageBox.Show("Fail!!");
}
//}
//catch
//{
//}
}
}
}
}
Tag : .NET, MySQL, C#
|
ประวัติการแก้ไข 2012-01-11 22:02:16 2012-01-11 22:03:18
|
|
|
|
|
Date :
2012-01-11 22:01:30 |
By :
techcom23 |
View :
2093 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอนนี้คุณติดตรงไหนครับ
|
|
|
|
|
Date :
2012-01-13 16:06:08 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ที่ **** ไว้อะครับ
|
|
|
|
|
Date :
2012-01-14 13:15:22 |
By :
techcom23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|