public static List <Customer> GetcustID(string username) { SqlConnection connection = MarinaDB.GetConnection(); List <Customer> results = new List <Customer>(); try { string sql = " select * from customer where username='******' "; SqlCommand command = new SqlCommand(sql, connection); SqlDataReader reader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection); while (reader.Read()) { Customer s = new Customer(); s.ID = Convert.ToInt32(reader["ID"].ToString()); results.Add(s); } } catch { } finally { connection.Close(); } return(results); }
public static List <Lease> GetLease() { SqlConnection connection = MarinaDB.GetConnection(); List <Lease> results = new List <Lease>(); try { string sql = "SELECT * FROM Lease"; SqlCommand command = new SqlCommand(sql, connection); SqlDataReader reader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection); while (reader.Read()) { Lease s = new Lease(); s.ID = Convert.ToInt32(reader["ID"].ToString()); results.Add(s); } } catch { } finally { connection.Close(); } return(results); }