2008/01/13

동적 MDB 생성하기

동적으로 MS Access DB를 만드는 코드.


// For Create MDB
#include <odbcinst.h>
#pragma link "Odbccp32.lib"


int __fastcall TDM::CreateMainDB()
{
AnsiString strMainDBPath;
strMainDBPath = m_strPath + "\MainDB.MDB";

if (FileExists(strMainDBPath))
{
ShowMessage("MainDB is Exists already!");
return -1;
}

strMainDBPath = "CREATE_DB=\"" + strMainDBPath

+ "\" General\0";

bool bCreated;
bCreated = SQLConfigDataSource(
NULL,
ODBC_ADD_DSN,
"Microsoft Access Driver (*.mdb)",
strMainDBPath.c_str() );

if (bCreated == true)
{
return 0;
}
else
return -2;
}


Original Post : http://neodreamer-dev.tistory.com/33

No comments :

Post a Comment