Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/141.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ sqlite3_step()在教程情况下返回SQLITE__C++_Sql_Sqlite - Fatal编程技术网

C++ sqlite3_step()在教程情况下返回SQLITE_

C++ sqlite3_step()在教程情况下返回SQLITE_,c++,sql,sqlite,C++,Sql,Sqlite,我是第一次使用SQLite3,但我无法找出以下错误。以下是相关线路: //open db; I checked, and sqlite3_open() returns 0 here (SQLITE_OK) rc = sqlite3_open(filename.c_str(),&db); //... //create & prepare query. string query = "SELECT * FROM MOCK_DATA;"; //I am positive MOCK_

我是第一次使用SQLite3,但我无法找出以下错误。以下是相关线路:

//open db; I checked, and sqlite3_open() returns 0 here (SQLITE_OK)
rc = sqlite3_open(filename.c_str(),&db);

//...

//create & prepare query.
string query = "SELECT * FROM MOCK_DATA;"; //I am positive MOCK_DATA exists and is non empty
sqlite3_stmt* stmt;
cout<<sqlite3_prepare(db,query.c_str(),0,&stmt,NULL)<<endl; //this prints 0: SQLITE_OK

//here we get the error 
cout<<sqlite3_step(stmt)<<endl; //returns 21: SQLITE_MISUSE
//打开数据库;我选中了,sqlite3\u open()在这里返回0(SQLITE\u OK)
rc=sqlite3_open(filename.c_str(),&db);
//...
//创建并准备查询。
string query=“从模拟数据中选择*”//我确信模拟U数据存在且不为空
sqlite3_stmt*stmt;

coutsqlite3\u prepare()
的第二个参数是SQL字符串的长度。零表示您的SQL为空。提供一个负值,例如
-1
,使sqlite3读取到C字符串中的第一个NUL字符