我在尝试启动我的应用程序时遇到此错误,我已将问题隔离到此代码功能,但我不明白为什么会发生这种情况......
void checkDB()
{
sqlite3 *db;
int rc=0;
size_t i;
char *zErrMsg = 0;
HMODULE hModule = GetModuleHandleW(NULL);
WCHAR path[MAX_PATH];
char buffer[MAX_PATH*4];
int len;
GetModuleFileNameW(hModule, path, MAX_PATH);
len =lstrlenW(path);
path[len-13]='\0';
buffer[0]='\0';
wcscat_s(path,sizeof(path),L"test.db\0");
GetFileAttributes(path);
if(INVALID_FILE_ATTRIBUTES == GetFileAttributes(path) && GetLastError()==ERROR_FILE_NOT_FOUND)
{
wcstombs_s(&i,buffer,sizeof(buffer), path, wcslen(path) );
rc= sqlite3_open(buffer,&db);
rc=sqlite3_exec(db,"create table Recipe (Recipe_Num INTEGER PRIMARY KEY AUTOINCREMENT, Recipe_Image VARCHAR(30), Recipe_Name VARCHAR(200))",NULL,0,&zErrMsg);
sqlite3_free(zErrMsg);
rc=sqlite3_exec(db,"create table Recipe_Step (Recipe_Num INTEGER, Step_Num INTEGER, Description VARCHAR(2000))",NULL,0,&zErrMsg);
if(rc!=SQLITE_OK)
{
sqlite3_close(db);
}
else
{
sqlite3_close(db);
}
}
}