Esempio n. 1
0
        public static void SaveRecord(EmployeeLayer emp)
        {
            // Open connection:

            if (connDB.State == ConnectionState.Closed)
            {
                connDB = UtilityDB.ConnectDB();
                cmd    = new SqlCommand();
            }
            cmd.Connection  = connDB;
            cmd.CommandText = string.Format("insert into Employees values({0},'{1}','{2}','{3}')", emp.EmployeeId, emp.FirstName, emp.LastName, emp.JobTitle);
            cmd.ExecuteNonQuery();
            connDB.Close();
        }
Esempio n. 2
0
        public static DataTable ReadEmployee()
        {
            if (connDB.State == ConnectionState.Closed)
            {
                connDB = UtilityDB.ConnectDB();
                cmd    = new SqlCommand();
            }
            cmd.Connection  = connDB;
            cmd.CommandText = "select * from employees";
            SqlDataReader reader = cmd.ExecuteReader();
            DataTable     dt     = new DataTable();

            dt.Load(reader);
            reader.Close();
            cmd.Dispose();
            connDB.Close();
            return(dt);
        }