private static Version GetTenantVersion() { using (SqlConnection conn = SQLAzureUtilities.GetActiveSqlConnection()) using (SqlCommand cmd = conn.CreateCommand()) { conn.Open(); cmd.CommandText = "GetTenantVersion"; cmd.CommandType = CommandType.StoredProcedure; SqlParameter name = cmd.Parameters.Add("@Name", SqlDbType.NVarChar); name.Value = sPContext.SPHostUrl.ToString(); using (SqlDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { reader.Read(); return(new Version(reader["Version"].ToString())); } else { throw new Exception("Unknown tenant: " + sPContext.SPHostUrl.ToString()); } } }//dispose conn and cmd }
private static void SetTenantVersion(Version newVersion) { using (SqlConnection conn = SQLAzureUtilities.GetActiveSqlConnection()) using (SqlCommand cmd = conn.CreateCommand()) { conn.Open(); cmd.CommandText = "UpdateTenantVersion"; cmd.CommandType = CommandType.StoredProcedure; SqlParameter name = cmd.Parameters.Add("@Name", SqlDbType.NVarChar); name.Value = sPContext.SPHostUrl.ToString(); SqlParameter version = cmd.Parameters.Add("@Version", SqlDbType.NVarChar); version.Value = newVersion.ToString(); cmd.ExecuteNonQuery(); }//dispose conn and cmd }