I'm working on Registration page for Lucky Draw system. I have created a database Employees which contain emp_id , emp_name, emp_deparment and attendance. I have set the column attendance to default value "Absent".But on database is show null.Click this link to view employees database.
So the process for registration is user need to scan their barcode using usb barcode scanner then the system will show their name and update the default value on Attendance column to "Present".I stuck on that part.Can anyone give me some ideas/solution.
attendance code :
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Attendance : System.Web.UI.Page
{
SqlCommand cmd = new SqlCommand();
SqlConnection con = new SqlConnection();
string str;
protected void Page_Load(object sender, EventArgs e)
{
con.ConnectionString = @"Data Source= (LocalDB)\MSSQLLocalDB; AttachDbFilename =
C:\Users\Nor Asyraf Mohd No\source\repos\LuckyDraw\LuckyDraw\App_Data\ticket.mdf;
Integrated Security = True";
con.Open();
txtText.Focus();
}
protected void btnSave_Click(object sender, EventArgs e)
{
}
void idcheck()
{
string selectQuery = "SELECT count(*) FROM EMPLOYEES where EMP_ID = '" + txtText.Text + "'";
SqlCommand cmd = new SqlCommand(selectQuery, con);
SqlDataReader myReader = null;
int count = Convert.ToInt32(cmd.ExecuteScalar());
if (count > 0)
{
myReader = cmd.ExecuteReader();
while (myReader.Read())
lblError.Text = myReader["EMP_NAME"].ToString();
lblError.ForeColor = System.Drawing.Color.Green;
}
else
{
lblError.Text = "Employee not available";
lblError.ForeColor = System.Drawing.Color.Red;
}
}
}