18.08.2014, 17:34
Hi all , i have a problem with SQLite , the problem is , it not inser into database i don't know why.
this :
format(BQuery, 900, "INSERT INTO `Business` (`ID`, `BInfo`) VALUES('%d','No Info')", bizid);
db_query(Database, BQuery);
don't work at OnGameModeInit i have :
Database = db_open("Biz.db");
db_query(Database, "CREATE TABLE IF NOT EXISTS `Business` (`ID`, `BInfo`)");
Код:
stock SetupBizFile() { if(!fexist(B_FILE_LOAD)) { print("=================================================================="); print("Batch file missing - skipping file setup and continuing to load..."); print("=================================================================="); print(" "); return 1; } new File: file,string[MAX_STRING_SIZE],filestring[MAX_STRING_SIZE],BQuery[900]; file = fopen(B_FILE_LOAD, io_read); print("================================================================"); print("Setting Up Business File System - Please Wait For Confirmation..."); print("================================================================"); print(" "); if(file) { for(new bizid=0;bizid<B_LIMIT;bizid++) { format(BQuery, 900, "INSERT INTO `Business` (`ID`, `BInfo`) VALUES('%d','No Info')", bizid); db_query(Database, BQuery); fread(file, filestring); if(sscanf(filestring,"p<,>fffs[56]ii", BizInfo[bizid][xpos], BizInfo[bizid][ypos], BizInfo[bizid][zpos], BizInfo[bizid][bname], BizInfo[bizid][cost], BizInfo[bizid][profit])){ format(string,sizeof(string), B_FILE_SAVE, bizid); file = fopen(string, io_write); format(filestring,sizeof(filestring), "INVALID FILE - NOT IN USE"); //fwrite(file, filestring); format(string, sizeof(string),"Business %d: Information is not present in load file - continuing to load...",bizid); print(string); print("----"); fclose(file); } else { bizcount++; BizInfo[bizid][bought] = 0; BizInfo[bizid][cashbox] = 0; BizInfo[bizid][fileid] = bizid; strmid(BizInfo[bizid][owner], DEFAULT_OWNER, 0, strlen(DEFAULT_OWNER), 255); BizInfo[bizid][puid] = CreatePickup(1272,2, BizInfo[bizid][xpos], BizInfo[bizid][ypos], BizInfo[bizid][zpos],-1); BizInfo[bizid][icoid] = CreateMapIcon(31,BizInfo[bizid][xpos],BizInfo[bizid][ypos],BizInfo[bizid][zpos],250); format(string, sizeof(string), "{0000FF}Business: {FF3300}%s \n{0000FF}Owner: {FFFF00}Nobody (Buy for $%d)",BizInfo[bizid][bname], BizInfo[bizid][cost]); bLabel[bizid] = CreateStaticLabel(string,0xFFFFFFFF,0,BizInfo[bizid][xpos],BizInfo[bizid][ypos],BizInfo[bizid][zpos]+1.5,30.0); format(string,sizeof(string),"Business %d (%s) successfully spawned",bizid,BizInfo[bizid][bname]); print(string); print("----"); SaveBusiness(bizid,BizInfo[bizid][fileid]); } } } return 1; }
format(BQuery, 900, "INSERT INTO `Business` (`ID`, `BInfo`) VALUES('%d','No Info')", bizid);
db_query(Database, BQuery);
don't work at OnGameModeInit i have :
Database = db_open("Biz.db");
db_query(Database, "CREATE TABLE IF NOT EXISTS `Business` (`ID`, `BInfo`)");