C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[10720] Re:dbf 파일에 필드 추가하는 방법!!??
개박살.U&I [inutero] 1343 읽음    2001-09-06 15:42

안녕하세요? 개박살입니다.

코딩상으로 Table을 만들고 또, 그곳에 필드를 추가할수있습니다.

그리고, 말씀하신 Field Editer는 Field를 Table에 만드는것이 아닙니다.

Table에 현재 존재하는 필드를 불러와서 속성값을 에디팅하고, 또, 특수필드 Calculate필드등.. 을

만드는 기능이지 테이블에 직접 필드를 만드는것은 아닙니다.

본론으로 돌아와서 Table에 필드를 만드는 예제는 역시 볼랜드 헬프에 있는것이 좋겠죠

그럼 갑니다..

----------------------------------------------------------------------------------------
if (!Table1->Exists) // Don't overwrite an existing table
{

  Table1->Active = false; // The Table component must not be active

  // First, describe the type of table and give it a name
  Table1->DatabaseName = "BCDEMOS";
  Table1->TableType = ttParadox;

  Table1->TableName = "CustInfo";

  // Next, describe the fields in the table

  Table1->FieldDefs->Clear();

  TFieldDef *pNewDef = Table1->AddFieldDef();
  pNewDef->Name = "Field1";
  pNewDef->DataType = ftInteger;
  pNewDef->Required = true;

  pNewDef = Table1->AddFieldDef();
  pNewDef->Name = "Field2";
  pNewDef->DataType = ftString;
  pNewDef->Size = 30;

  // Next, describe any indexes
  Table1->IndexDefs->Clear();
  /* the 1st index has no name because it is a Paradox primary key */
  Table1->IndexDefs->Add("","Field1", TIndexOptions() <<ixPrimary << ixUnique);

  Table1->IndexDefs->Add("Fld2Index","Field2", TIndexOptions() << ixCaseInsensitive);

  // Now that we have specified what we want, create the table

  Table1->CreateTable();
}
----------------------------------------------------------------------------------------

이것이네요... 보는바와 같이

  TFieldDef *pNewDef = Table1->AddFieldDef();  // 테이블에 빈필드를 추가하고 그포인터를 넘겨준다.
  pNewDef->Name = "Field1";                    // 받는 포인터를 이용해서 필드의 이름과 속성을 설정
  pNewDef->DataType = ftInteger;               // 타입은 Integer 형
  pNewDef->Required = true;                    // 필수속성 'True'

이렇게 만드는 군요 그럼 참고하세요~~

배준형 님이 쓰신 글 :
: dbf를 table로 불러와서 필드를 추가 하려고 합니다. 필드를 추가하는데 field editer 라는게 있더군요.
: 코딩상에서 사용하는 방법은 없을까요? query도 사용해 봤지만... 쉽지가 않더군요. 도와주세용...

+ -

관련 글 리스트
10711 dbf 파일에 필드 추가하는 방법!!?? 배준형 1029 2001/09/06
10720     Re:dbf 파일에 필드 추가하는 방법!!?? 개박살.U&I 1343 2001/09/06
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.