|
안녕하세요? 개박살입니다~
테이블을 생성하는 두가지 방법이 있습니다 (제가 알기론.. ^^)
먼저, 추천하고픈 방법은 SQL문으로 생성을 하는 방법입니다. (쉬우니까!)
SQL문은, ADOCommand나 기타 컴포넌트로 실행을 하시면 되죠 흠.. 문법은,
CREATE TABLE TableName (고객번호 Char(20), 고객이름 Char(10));
이런식으로하면.. 흠.. 한번해보세요!! 그럼 알껍니다 ^^;
두번째는, 코딩으로 생성하는 방법입니다. 이건 해본기억이 있어서 예제를 찾아봐도 지워버렸나 봅니다..
뭐 볼랜드 TTable을 가지고 생성하는 예제가 있어서 이걸 올립니다. (혹시 찾으셨나.. ??)
ADOTable은 좀 다를꺼니까 컨버트 해보세요!!
그럼 참고정도는 하세요~~
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
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();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
박보연 님이 쓰신 글 :
: StringGrid의 내용을 MDB로 저장하는 작업을 하고 있습니다.
:
: StringGrid와 같은 형태의 Table을 미리 만들어 놓고 하는건 되는데..
:
: StringGrid의 형태가 달라질 수 있고, 테이블 개수가 달라질 수 있기 때문에
:
: Table을 StringGrid의 형태에 따라 동적으로 생성하고 싶습니다.
:
: 아시는 분! 좀 알려주세요~~
:
:
:
:
|