Foreach循环仅跟随C#中SQL Server中的数据表的第一行进行指纹验证 [英] Foreach loop follow only first row of data table in SQL Server in C# for fingerprint verification

查看:91
本文介绍了Foreach循环仅跟随C#中SQL Server中的数据表的第一行进行指纹验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一个问题,我目前正在开发一个生物识别考勤系统项目,并且卡在指纹存储在数据库中的位置以及当我检索指纹进行验证时,它只检索第一个记录,而不检索其他行.数据表请在这方面帮助我.

That is my first question here I am currently working on an project Biometric attendance system and I am stuck at the place the fingerprints are saved in the database and when I retrieve fingerprints for verification and it retrieves only first record not others rows of datatable please help me in this regard.

这是我的代码:

protected override void Process(DPFP.Sample Sample)
{
    con.Open();

    SqlCommand cmd = new SqlCommand("SELECT *FROM EmpRegistration", con);

    SqlDataAdapter sda = new SqlDataAdapter(cmd);
    DataTable dt = new DataTable();
    sda.Fill(dt);

    if (dt.Rows.Count > 0)
    {
        foreach (DataRow dr in dt.Rows)
        {
            byte[] _img_ = (byte[])dr["Finger"];
            MemoryStream ms = new MemoryStream(_img_);
            DPFP.Template Template = new DPFP.Template();
            Template.DeSerialize(ms);

            DPFP.Verification.Verification Verificator = new DPFP.Verification.Verification();

            con.Close();

            base.Process(Sample);

            // Process the sample and create a feature set for the enrollment purpose.
            DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification);

            // Check quality of the sample and start verification if it's good
            // TODO: move to a separate task
            if (features != null)
            {
                // Compare the feature set with our template
                DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result();
                Verificator.Verify(features, Template, ref result);
                UpdateStatus(result.FARAchieved);

                if (result.Verified)
                {
                    MakeReport("Verified");

                    try
                    {
                        con.Open();

                        SqlDataReader myReader = null;

                        SqlCommand myCommand = new SqlCommand("select * from EmpRegistration", con);

                        myReader = myCommand.ExecuteReader();

                        while (myReader.Read())
                        {
                            txtname.Text = myReader["EmpName"].ToString();
                            txtcnic.Text = myReader["CNIC"].ToString();
                        }

                        con.Close();
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.ToString());
                    }

                    break;
                }
                else if (result.Verified == false)
                {
                    MakeReport("Employee not registered");
                }
            }
        }
    }
}

推荐答案

它实际上遍历了所有记录,但是在循环结束之后,您只对最后一条记录进行了反序列化.

It actually goes through all records, but after the loop ends you just have the last record deserialized.

反序列化每个记录后,必须使用验证器检查指纹的有效性.

After Deserializing each record, you must use a Validator to check the validity of the finger print.

看看 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆