i was have the this problem in c# 2005
the problem was the way that i saved the template in the DB
i have modify the sql command and used stored procedure and called it in the function addTemplate become
public bool addTemplate(TTemplate tpt, ref int id, string Name)
{
//OleDbCommand cmdInsert = null;
////OleDbParameter dbParamInsert = null;
////OleDbParameter dbParamName = null;
//OleDbCommand cmdSelect = null;
try
{
System.Byte[] temp = new System.Byte[tpt._size + 1];
System.Array.Copy(tpt._tpt, 0, temp, 0, tpt._size);
_command.CommandText = "AddFingerPrint";
_command.CommandType = CommandType.StoredProcedure;
if (_command.Parameters.Count <= 0)
{
_command.Parameters.Add("@Template", SqlDbType.Image);
_command.Parameters.Add("@Name", SqlDbType.NVarChar, 50);
}
_command.Parameters["@Template"].Value = temp;
_command.Parameters["@Name"].Value = Name;
if (_connection.State == ConnectionState.Open)
_command.ExecuteNonQuery();
//_command.CommandType = CommandType.Text;
}
catch(Exception ex)
{
//return false;
string exc = ex.Message;
}
try
{
// Create SQL command containing ? parameter for BLOB.
_command.CommandText = "SELECT top 1 ID FROM enroll ORDER BY ID DESC";
id = System.Convert.ToInt32(_command.ExecuteScalar());
}
catch
{
return false;
}
return true;
}
and i have create function to retrieve the name from the DB when found finger print
public DataSet ReadIDfromDB(int id)
{
DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter();
_connection.ConnectionString = CONNECTION_STRING;
_command.CommandText = "Select ID,Name From enroll where ID=" + id;
sda.SelectCommand = _command;
sda.Fill(ds);
return ds;
}
[/code]