예제 #1
0
        private static Country GetCountryFromReader(IDataReader dataReader)
        {
            Country country = new Country();
            country.CountryID = DBHelper.GetInt(dataReader, "CountryID");
            country.Name = DBHelper.GetString(dataReader, "Name");

            return country;
        }
예제 #2
0
        public static void UpdateCountry(Country country)
        {
            string sqlQuery = "UPDATE Country SET Name=@Name WHERE CountryID=" + country.CountryID;

            Database db = new SqlDatabase(DBHelper.GetConnectionString());
            DbCommand dbCommand = db.GetSqlStringCommand(sqlQuery);
            db.AddInParameter(dbCommand, "Name", DbType.String, country.Name);

            db.ExecuteNonQuery(dbCommand);
        }
예제 #3
0
        public static Country InsertCountry(Country country)
        {
            string sqlQuery = "INSERT INTO Country(Name) " +
                " VALUES(@Name);SELECT @@Identity";

            Database db = new SqlDatabase(DBHelper.GetConnectionString());
            DbCommand dbCommand = db.GetSqlStringCommand(sqlQuery);
            db.AddInParameter(dbCommand, "Name", DbType.String, country.Name);
            country.CountryID = Convert.ToInt32(db.ExecuteScalar(dbCommand));

            return country;
        }
예제 #4
0
 public static void UpdateCountry(Country country)
 {
     CountryDB.UpdateCountry(country);
 }
예제 #5
0
 public static Country InsertCountry(Country country)
 {
     return CountryDB.InsertCountry(country);
 }