테이블 형식 모드에서 데이터베이스는 테이블 형식 모델의 모든 개체에 대한 컨테이너입니다.
데이터베이스 표현
데이터베이스는 테이블 형식 모델을 형성하는 모든 개체가 상주하는 위치입니다. 데이터베이스에 포함된 개발자는 연결, 테이블, 역할 등과 같은 개체를 찾습니다.
AMO의 데이터베이스
AMO를 사용하여 테이블 형식 모델 데이터베이스를 관리하는 경우 AMO의 Database 개체는 테이블 형식 모델의 데이터베이스 논리 개체와 일대일로 일치합니다.
비고
데이터베이스 개체에 액세스하려면 AMO에서 사용자가 서버 개체에 대한 액세스 권한을 갖고 해당 개체에 연결해야 합니다.
ADOMD.Net 데이터베이스
ADOMD를 사용하여 테이블 형식 모델 데이터베이스를 참조하고 쿼리하는 경우 개체를 통해 AdomdConnection 특정 데이터베이스에 대한 연결을 가져옵니다.
다음 코드 조각을 사용하여 특정 데이터베이스에 직접 연결할 수 있습니다.
using ADOMD = Microsoft.AnalysisServices.AdomdClient;
...
ADOMD.AdomdConnection currrentCnx = new ADOMD.AdomdConnection("Data Source=<<server\instance>>;Catalog=<<database>>");
currrentCnx.Open();
...
또한 닫혀 있지 않은 기존 연결 개체를 통해 다음 코드 조각과 같이 현재 데이터베이스를 다른 데이터베이스로 변경할 수 있습니다.
currentCnx.ChangeDatabase("myOtherDatabase");
AMO의 데이터베이스
AMO를 사용하여 데이터베이스 개체를 관리하는 경우 개체로 Server 시작합니다. 그런 다음, 데이터베이스 컬렉션에서 데이터베이스를 검색하거나 컬렉션에 데이터베이스를 추가하여 새 데이터베이스를 만듭니다.
다음 코드 조각은 데이터베이스가 존재하지 않는지 확인한 후 서버에 연결하고 빈 데이터베이스를 만드는 단계를 보여 주는 코드 조각입니다.
AMO.Server CurrentServer = new AMO.Server();
try
{
CurrentServer.Connect(currentServerName);
}
catch (Exception cnxException)
{
MessageBox.Show(string.Format("Error while trying to connect to server: [{0}]\nError message: {1}", currentServerName, cnxException.Message), "AMO to Tabular message", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
newDatabaseName = DatabaseName.Text;
if (CurrentServer.Databases.Contains(newDatabaseName))
{
return;
}
try
{
AMO.Database newDatabase = CurrentServer.Databases.Add(newDatabaseName);
CurrentServer.Update();
}
catch (Exception createDBxc)
{
MessageBox.Show(String.Format("Database [{0}] couldn't be created.\n{1}", newDatabaseName, createDBxc.Message), "AMO to Tabular message", MessageBoxButtons.OK, MessageBoxIcon.Error);
newDatabaseAvailable = false;
}
AMO를 사용하여 데이터베이스 표현을 만들고 조작하는 방법에 대한 실질적인 이해는 테이블 형식 AMO 2012 샘플의 소스 코드를 참조하세요. 특히 다음 소스 파일을 체크 인합니다. Database.cs. 샘플 코드는 여기에 설명된 논리적 개념에 대한 지원으로만 제공되며 프로덕션 환경에서 사용하면 안 됩니다.