sqlite查询数据库

//每次只返回一条记录,如果要保存所有记录,不能用局部变量。
int _callback(void *olt_temp, int argc, char *value[], char *name[])
{
	//olt_temp: 与sqlite3_exec中的第四个参数相同
	//argc: 字段数
	//value: 值 
	//name: 字段名
	return 0; //0表示成功,继续收到其它数据,
	          //其它值表示终止,不会再继续收到数据。
}

sqlite3* m_pDB;
if(0 != ::sqlite3_open16(path, &m_pDB))
{
	//error
	//return false;
}


int ire = sqlite3_exec(pDB, pSql, _callback, NULL, &m_pErrMsg);
if (NULL != m_pErrMsg)
{
	::sqlite3_free(m_pErrMsg);
	m_pErrMsg = NULL;
}


if (0 != ire)
{
	//执行失败
	//return false;
}
sqlite3_close(m_pDB);


猜你喜欢

转载自blog.csdn.net/project4gogo/article/details/10162465