Monday 15 February 2010

ios - SQL Error: Not an Error -


More SQLite problems, so my interface is as follows (this is all in meters):

 < Code> @interface Search () @property (strong, nonatomic) NSString * DatabasePath; // Path SQL database database file @ property (strong, nonatomic) NSString * databaseName; @protecti (nonatic) sqlite3 * database; @end   

and init is as follows:

  - (id) init {if ((auto = [super init])) {self.databaseName = DB_NAME; NSArray * documentPaths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, yes); NSString * DocumentsDIR = [DocumentPath ObjectAntIndex: 0]; _databasePath = [Document Deer Stringbapment Pathcompany: self.databaseName]; [Self check and creite database]; If (sqlite3_open_v2 ([self.databasePath UTF8String], & amp; _database, SQLITE_OPEN_READWRITE, zero) = SQLITE_OK!) {[[[UIAlertView alloc] initWithTitle: @ "lost" message: @ representatives did not "database file": CancelButtonTitle not Equal to: @ "OK" other button titles: zero, zero] shows]; } Else {NSLog (@ "% s: sqlite3_open_v2 Error:% s", __FUNCTION__, sqlite3_errmsg (self.database)); }}   

error which is logged in the init return: sqlite3_open_v2 error: no error . In my searches, I've heard that SQLite does not return an error when it points to a non-existent database but I'm not sure why the database will not exist. Copy function I'm using (who I was and it seemed Prior to that work) is as follows:

  - Check (zero) checkAndCreateDatabase {// if SQL database has already been saved on users' phones, if not, then copy it to BOOL dbExists; // Create a FileManager object, we have to copy to check // status of database access and this would have required NSFileManager * filemanager = [NSFileManager defaultManager]; // Check whether the database has already been created in the user file system DBExists = [File Manager FileExtSet Path: _databasePath]; // If the database already exists then return without doing anything (dBexists) {return; } // If not, database receive path forward database Continue filesystem // application package to copy the files to users of the application NSString * databasePathFromApp = [[[NSBundle mainBundle] Snsadnpath] Stringbapingingpathkanpani: _databaseName]; Copy the database file system from // package // file manager copyItemAtPath: databasePathFromApp toPath: _databasePath error: zero]; NSError * Error = Zero; If ([filemanager copyItemAtPath: databasePathFromApp toPath: _databasePath error: & amp; error]!) {NSLog (@ "% s: copyItemAtPathError:% @", __FUNCTION__, error); }}   

Finally, I have verified in the iOS Simulator Documents Directory that the database exists, and is trying to execute the query on it. Why am I getting this error?

Never worked with SQLLite like this, I just want to mention that in the code above Your statement is called, when sqlite_open_v2 == SQL_OK . So in that case, there is no error in return and everything is fine ?!

No comments:

Post a Comment