This is the definition of this integer.
# Define sqlite_ OK0/* Successful result */
/* Beginning-of-error-codes */
# Define sqlite_error1/* SQL error or missing database */
# Define sqlite_internal2/* Internal logic error in SQLite */
# Define sqlite_perm3/* Access permission denied */
# Define sqlite_abort4/* Callback routine requested an abort */
# Define sqlite_busy5/* The database file is locked */
# Define sqlite_locked6/* A table in the database is locked */
# Define sqlite_nomem7/* A malloc () failed */
# Define sqlite_readonly8/* Attempt to write a readonly database */
# Define sqlite_interrupt9/* Operation terminated by sqlite3_interrupt ()*/
# Define sqlite_ioerr10/* Some kind of disk I/O error occurred */
# Define sqlite_corrupt11/* The database disk image is malformed */
# Define sqlite_notfound12/* Not used. Table or record not found */
# Define sqlite_full13/* Insertion failed because database is full */
# Define sqlite_cantopen14/* Unable to open the database file */
# Define sqlite_protocol15/* Not used. database lock protocol error */
# Define sqlite_empty16/* Database is empty */
# Define sqlite_schema17/* The database schema changed */
# Define sqlite_toobig18/* String or blob exceeds size limit */
# Define sqlite_constraint19/* Abort due to Constraint Violation */
# Define sqlite_mismatch20/* Data Type Mismatch */
# Define sqlite_misuse21/* Library used incorrectly */
# Define sqlite_nolfs22/* Uses OS features not supported on Host */
# Define sqlite_auth23/* Authorization denied */
# Define sqlite_format24/* Auxiliary database format Error */
# Define sqlite_range25/* 2nd parameter to sqlite3_bind out of range */
# Define sqlite_notadb26/* File opened that is not a database file */
# Define sqlite_row100/* Sqlite3_step () has another row ready */
# Define sqlite_done101/* Sqlite3_step () has finished executing */
WhenWhen using the sqlite3_prepare_v2 () function, the SQL statement is compiled into a struct (sqlite3_stmt) in SQLite ).
This struct contains information about the SQL statements to be executed.
Normally, 0 is returned. In other cases, other values are returned.
I will take 1 as an example to briefly introduce how to solve the error:
# Define sqlite_error1/* SQL error or missing database */
We try to use the followingCodeTo test:
// Get the path to the specified ents directory and append the databasename
Nsstring* Documentpaths =Nssearchpathfordirectoriesindomains(Nsdocumentdirectory,Nsuserdomainmask,Yes);
Nsstring* Documentsdir = [documentpathsObjectatindex:0];
Databasepath= [DocumentsdirStringbyappendingpathcomponent:Databasename];
Nsarray* Paths =Nssearchpathfordirectoriesindomains(Nsdocumentdirectory,Nsuserdomainmask,Yes);
Nsstring* Documentsdirectory = [pathsObjectatindex:0];
Nsstring* Path = [documentsdirectoryStringbyappendingpathcomponent:Databasename];
Nsfilemanager* Filemanager = [Nsfilemanager Defamanager Manager];
The path above shows the path of the database to be connected. Sometimes, after your project is created, the database will be copied to this path during running. If the database changes in the middle, it may not be copied, then the database files in this path will be different from those in your project. The path contains a zero-byte empty database. Therefore, even if you discover the existence of a database, you cannot guarantee thatThe struct is correct.
BoolFind = [filemanagerFileexistsatpath: Path];
If(FIND ){
Nslog(@ "Database file have already existed .");
If(Sqlite3_open([PathUtf8string], &Database _)! =Sqlite_ OK){
Sqlite3_close(Database _);
Nslog(@ "Error: open database file .");
Return No;
}
Return Yes;
}
Else{
Sqlite3_close(Database _);
Nslog(@ "Error: open database file .");
Return No;
}
The above is the open code. Next, I will share with you how to create a sqlitehelper class and its methods.
Http://alexliu.cnblogs.com