private static Country GetCountryFromReader(IDataReader dataReader) { Country country = new Country(); country.CountryID = DBHelper.GetInt(dataReader, "CountryID"); country.Name = DBHelper.GetString(dataReader, "Name"); return country; }
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); }
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; }
public static void UpdateCountry(Country country) { CountryDB.UpdateCountry(country); }
public static Country InsertCountry(Country country) { return CountryDB.InsertCountry(country); }