public static List <Rail> GetRail() { List <Rail> RailList = new List <Rail>(); SqlConnection conn = GetConnection(); string QuerySel = "Select * from RailTable Order by Name_Rail"; SqlCommand SelComm = new SqlCommand(QuerySel, conn); try { conn.Open(); SqlDataReader reader = SelComm.ExecuteReader(); while (reader.Read()) { Rail rail = new Rail(); rail.IdRail = (int)reader["IdRail"]; rail.NameRail = reader["NameRail"].ToString(); rail.Motor_steps = reader["Motor_steps"].ToString(); rail.Micro_steps = reader["Micro_steps"].ToString(); rail.Ball_screw = reader["Ball_gear"].ToString(); rail.Gear_box = reader["Gear_box"].ToString(); RailList.Add(rail); } reader.Close(); } catch (SqlException ex) { throw ex; } finally { conn.Close(); } return(RailList); }
public static List<Rail> GetRail() { List<Rail> RailList = new List<Rail>(); SqlConnection conn = GetConnection(); string QuerySel = "Select * from RailTable Order by Name_Rail"; SqlCommand SelComm = new SqlCommand(QuerySel, conn); try { conn.Open(); SqlDataReader reader = SelComm.ExecuteReader(); while (reader.Read()) { Rail rail = new Rail(); rail.IdRail = (int)reader["IdRail"]; rail.NameRail = reader["NameRail"].ToString(); rail.Motor_steps = reader["Motor_steps"].ToString(); rail.Micro_steps = reader["Micro_steps"].ToString(); rail.Ball_screw = reader["Ball_gear"].ToString(); rail.Gear_box = reader["Gear_box"].ToString(); RailList.Add(rail); } reader.Close(); } catch (SqlException ex) { throw ex; } finally { conn.Close(); } return RailList; }