2014-09-08 7 views
0

외부 데이터베이스의 데이터를 Kentico 온라인 마케팅 담당자에게 매핑하기위한 모듈을 개발하고자합니다. 기본 제공 OM.Contact 클래스의 모든 표준 및 사용자 정의 필드에 대한 필드 이름 및 캡션을 나열하는 쉬운 방법이 있습니까? 외부 DB에서Kentico 연락처 입력하기

답변

0

얻기 데이터

데이터베이스에서 데이터를 얻을 수 및 메모리에 넣어하는 방법의 톤이있다. Kentico에서 데이터를 얻기 Kentico

에서 데이터 가져 오기

//Set the connection string 
    string ConnectionString = externalDBConnectionString; 

    //Sets the text of the query we want to execute on the database to a variable called queryText 
    string queryText = "SELECT * FROM Table"; 

    //Creates a new instance of the SqlDataAdapter object and calls it "adapter". 
    //We pass in the text of the query we want to execute on the database, and the connetion string to the database. 
    SqlDataAdapter adapter = new SqlDataAdapter(queryText, ConnectionString); 

    //Instantiate a dataset. 
    DataSet ds = new DataSet(); 

    //Fills the dataset with the data retrieved by our query on the database. 
    adapter.Fill(ds); 

더 쉽게됩니다 : 여기에 하나의 범용 I는 꽤 사용하는 스크립트입니다. Kentico는 단순한 데이터 구조 인 Info 개체와 InfoObject를 데이터로 채우고 Kentico DB에서 CRUD 작업을 실행하는 메서드를 포함하는 InfoProvider 개체를 사용하는 API를 제공합니다.

그들은 다음과 같이 작동 :

// Instantiate a ContactInfo object 
    ContactInfo ci = new ContactInfo(); 

    // Populate it with data using the InfoProvider's GetContactInfo() method 
    ci = new ContactInfoProvider.GetContactInfo(ContactID); 

    // Shorthand 
    ContactInfo ci = new ContactInfoProvider.GetContactInfo(ContactID); 

    // Assign values to your server control properties using the properties of the Info object 
    txtFormField.Text = ci.ContactName; 

후, 서로 필드와 해당 데이터 유형을 매핑 할 필요 앞뒤로 외부 DB와 Kentico DB에서 데이터를 이동 실행 형식이 지정된 데이터가있는 DB에 대한 쿼리입니다.

+0

사실 코드의 연락처 필드 목록을 채우고 처리를 위해 컬렉션에 저장해야합니다. 연락처 필드 목록을 동적으로 결정할 수 있어야합니다. – emroc

+0

아, 나는 너를 오해했다. ContactInfo 및 ContactInfoProvider 객체를 사용하려고 할 것입니다. 오늘 저녁에 내 대답을 업데이트하여 InfoProvider 객체를 사용하여 Kentico 데이터베이스에서 CRUD 작업을 실행하는 방법을 보여줍니다. 외부 DB의 데이터로 데이터 세트를 채우고 InfoObject에 삽입 한 다음 InfoProdiver 객체로 만들기/업데이트 만하면됩니다. 그 동안 Kentico에서이 가이드를 확인하실 수 있습니다 (184 페이지 시작). 버전 6이지만 클래스는별로 바뀌지 않았을 것입니다. http://devnet.kentico.com/docs/6_0/KenticoCMS_OnlineMarketingGuide.pdf – Jerreck

+0

아, ContactInfo 객체에 전달한 데이터를 사용하여 양식 필드도 있습니다. 외부 DB 또는 Kentico의 데이터로 Info 객체를 채울 지 여부는 중요하지 않습니다. – Jerreck