using System; using System.Collections.Generic; using System.Data; 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; private string connectionString; 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"; txtText.Focus(); } protected void btnSave_Click(object sender, EventArgs e) { idcheck(); using (SqlConnection connection = new SqlConnection(connectionString)) { using (SqlCommand command = connection.CreateCommand()) { command.CommandText = "UPDATE EMPLOYEES SET Attendance = 'Present' WHERE EMP_ID = @id"; command.Parameters.AddWithValue("@id", txtText.Text); connection.Open(); command.ExecuteNonQuery(); connection.Close(); } } } public void idcheck() { string query = "select EMP_ID from EMPLOYEES where EMP_ID='" + txtText.Text + "'"; SqlDataAdapter ada = new SqlDataAdapter(query, con); DataTable dt = new DataTable(); ada.Fill(dt); if (dt.Rows.Count > 0) { lblError.Text = dt.Rows[0]["EMP_NAME"].ToString(); } } protected void Button1_Click1(object sender, EventArgs e) { Response.Redirect("Default.aspx"); } }
string query = "select EMP_ID from EMPLOYEES where EMP_ID='" + txtText.Text + "'";
btnSave_Click
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)