刷卡并插入数据库时​​识别员工的姓名 [英] Identify firstname of employee when RFID card is swiped and insert into database

查看:62
本文介绍了刷卡并插入数据库时​​识别员工的姓名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图解决这个问题很长一段时间但尚未实现。我的问题是我试图将我的字段值(firstname,rfid,sdt(datetime))插入datatab并显示该数据的报告。



现在方案是rfid卡可以在一天内被员工刷过多次我将数据存储到我的管理表中并且我已成功完成显示和存储rfid和sdt字段到表中但是必须从表Admin中获取firstname rfid在注册员工时分配给他们的唯一标签。



我已尝试加入,多个查询到一个但到目前为止没有任何作用。存储这两个值的查询是:



我尝试过:



I have been trying to resolve this for quite some time now but not achieved yet. My problem is i am trying to insert values of my fields(firstname,rfid,sdt(datetime)) into datatab and display a report of that data.

now the scenario is rfid card can be swiped a number of times throughout the day by the employee i am storing that data into my admin table and i have successfully accomplished displaying and storing rfid and sdt fields into the table but firstname must be fetched from table Admin in which unique tag of rfid at the time of registration of employee is assigned to them.

I have tried joins,multiple queries into one but nothing worked for me so far. query to store those two values is :

What I have tried:

SqlConnection con = new SqlConnection(str);
con.Open();
SqlCommand cmd = new SqlCommand("Insert into Datatab(firstname) Select Distinct firstname from Admin", con);
cmd.Parameters.AddWithValue("@firstname", txtname.Text);
//       cmd.Parameters.AddWithValue("@rfid", txtname.Text);
cmd.ExecuteNonQuery();
con.Close();



我想要使用该员工的rfid来刷他/她卡的n个特定员工的姓名保存到数据库中。


I want the name of the specific employee who swipes his/her card for n no of times with rfid of that employee to be saved into the database.

推荐答案

不要。

执行此操作的正确方法是保留用户数据您的Admin表,与您分配的Rfid标记代码一样。然后,当您获得标记滑动时,将标记代码存储在Datatab中(也可能是时间戳),但没有其他信息。

如果要检索用户数据和时间戳,请使用JOIN将Datatab中的rfid标记与Admin表中的用户名相关联。



如果你不这样做,你就是在复制信息,浪费数据库空间,并可能在以后引起自己的问题。考虑一下:如果用户更改名称会怎么样?在设计合理的系统中,必须将更改记录在一个位置。在你的网站中,可能有数千个需要更新。
Don't.
The "proper" way to do this is to keep the user data in your Admin table, as you are with the Rfid tag code that is assigned. Then when you get a tag swipe, you store the tag code in Datatab (and probably a timestamp as well) but no other information.
When you want to retrieve the user data and timestamp you use a JOIN to correlate the rfid tag from the Datatab to the username from the Admin table.

If you don't do it this way, you are duplicating information, wasting DB space, and potentially causing yourself problems later. Consider this: what if the user changes their name? In a properly designed system, the change has to be recorded in one location. In yours, there are potentially thousands that need updating.


这篇关于刷卡并插入数据库时​​识别员工的姓名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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