|
아래와 같이 동적으로 DB Table 생성 프로그램을 작성해서 실행하면
다른 폴더에서는 잘 작동하는데
'숭'이라는 단어가 들어있는 폴더에서 실행하면 데이블을 생성할 수 없다고 나오는데
왜 그렇죠?
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <BDE.hpp>
#include <DBTables.hpp>
#include "unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::CreateAlias()
{
//TODO: Add your source code here
//alias 생성
try
{
String Alias = GetCurrentDir();
hDBISes h;
DbiInit(NULL);
DbiStartSession("dummy", h, "");
DbiAddAlias(NULL, "Data", "PARADOX", ("PATH:" + Alias).c_str(), true);
DbiCloseSession(h);
DbiExit;
}
catch (...)
{
MessageBox(Handle, "Error Creating Alias", "Error", 0);
return;
}
}
void __fastcall TForm1::DeleteAlias()
{
//TODO: Add your source code here
try //alias 삭제
{
DbiDeleteAlias(NULL, "Data");
}
catch (...)
{
MessageBox(Handle, "Error Deleting Alias", "Error", 0);
return;
}
}
void __fastcall TForm1::ConnectDataTables()
{
String Path = GetCurrentDir();
ShowMessage(Path);
String product = Path + "Product.db";
if(!FileExists(product))
CreatePodoProductTable();
}
void __fastcall TForm1::CreatePodoProductTable()
{
//TODO: Add your source code here
TTable *table;
try
{
table = new TTable(this);
table->DatabaseName = "Data";
table->TableType = ttParadox ;
table->TableName = "Product.db";
table->FieldDefs->Add("Number", ftString, 19, false);
table->FieldDefs->Add("CropDate", ftString, 10, true);//출하일
table->FieldDefs->Add("ShipmentPlace",ftString, 16, true);//출하지
table->FieldDefs->Add("TreeKind", ftString, 12, true);//품종
table->FieldDefs->Add("BoxWeight", ftString, 6, true);//상자 무게
table->IndexDefs->Add("", "Number", TIndexOptions() << ixUnique << ixPrimary);
table->CreateTable();
}
catch (...)
{
MessageBox(Handle, "Error Creating Tables", "Error", 0);
delete table;
return;
}
delete table;
}
void __fastcall TForm1::FormCreate(TObject *Sender)
{
DeleteAlias();
CreateAlias();
ConnectDataTables();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
DeleteAlias();
}
//---------------------------------------------------------------------------
|