C++ SQLite 返回一些值?

标签 c++ sql sqlite parsing recv

我正在编写一个使用 SQLite 的服务器端程序。当客户端登录时,我想从 Userinfo 表中获取其信息。

它的列是

  • 用户号(int),
  • 金钱(int),
  • 银行货币(int),
  • 性别(字符串),
  • 姓名,
  • 姓氏

我想将这些信息写入用户结构

struct userstruct
{
  int userno;
  int money;
  int bankmoney
  ....
}

当用户登录时,我想创建一个新的结构并通过 SQLite 从该表设置用户信息。

最佳答案

以下内容:

static int callback(void *data, int argc, char **argv, char **azColName)
  • void *data - 可用于给出指向对象的指针 - 又名 this 或其他任何内容,可以为 null
  • int argc - 列数 - 所选记录数
  • char **argv - 列值数组。
  • char **azColName - 列名称数组

顺便说一句:更好地使用准备 - 绑定(bind) - 步骤,如下面的示例,这样它就可以在没有回调的情况下工作:

sqlite3_prepare_v2(db, "select distinct name, age from demo where age > ? order by 2,1;", -1, &stmt, NULL);

sqlite3_bind_int(stmt, 1, 16);                                                                  /* 1 */

while ( (rc = sqlite3_step(stmt)) == SQLITE_ROW) {                                              /* 2 */
    printf("%s is %d years old\n", sqlite3_column_text(stmt, 0), sqlite3_column_int(stmt, 1));  /* 3 */
}

关于C++ SQLite 返回一些值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47418273/

相关文章:

android - 使用 Android 搜索对话框搜索多个数据库列

swift - 当更新到最新的 Xcode 时出现错误 : "could not build objective-c module csqlite"

c++ - 使用构造函数从函数返回对象

c++ - 什么配置文件格式允许包含其他文件和继承设置?

php - 如何反转 MySQL 查询的输出顺序

java - MySQL、Java 和时区

node.js - 使用sequelize比较 Node js中的日期

iphone - C++ 中的静态初始化与 Objective-C 混合

c++ - 查找行中下一个像素的优雅方法

c# - 使这个 SQL 查询更有效率