public int InsertData(DataOrm dataOrm) { cmd.CommandText = $"insert into Employee values({dataOrm.DataID},'{dataOrm.DataInfo}',{dataOrm.DataKey})"; cnn.Open(); int affetcted = cmd.ExecuteNonQuery(); cnn.Close(); return(affetcted); }
public int UpdateData(DataOrm dataOrm) { cmd.CommandText = $"update Employee set EmpName='{dataOrm.DataInfo}',EmpDept={dataOrm.DataKey} where EmpID={dataOrm.DataID}"; cnn.Open(); int affetcted = cmd.ExecuteNonQuery(); cnn.Close(); return(affetcted); }
public DataOrm GetData(int id) { cmd.CommandText = $"select * from Employee where EmpID={id}"; cnn.Open(); DataOrm orm = null; SqlDataReader reader = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection); if (reader.Read()) { orm = new DataOrm { DataID = (int)reader[0], DataInfo = reader[1].ToString(), DataKey = (int)reader[2] } } ; reader.Close(); return(orm); }