int SQCloudVMColumnCount (SQCloudVM *vm);


The SQCloudVMColumnCount returns the number of columns in the result set returned by the prepared statement. If this routine returns 0, that means the prepared statement returns no data (for example an UPDATE). However, just because this routine returns a positive number does not mean that one or more rows of data will be returned. A SELECT statement will always have a positive SQCloudVMColumnCount but depending on the WHERE clause constraints and the table content, it might return no rows.

This function resembles the sqlite3_column_count SQLite APIs.


Return value An int with the number of columns.


int main (int argc, const char * argv[]) {
    // setup config
    SQCloudConfig config = {0};
    config.username = "myusername";
    config.password = "mypassword"

    SQCloudConnection *conn = SQCloudConnect("myproject.sqlite.cloud", SQCLOUD_DEFAULT_PORT, &config);
    if (SQCloudIsError(conn)) {
        printf("ERROR connecting: %s (%d)\n", SQCloudErrorMsg(conn), SQCloudErrorCode(conn));
        return -1;
    } else {
        printf("Connection to host OK...\n\n");

    // choose a database first
    SQCloudResult *r = SQCloudExec(conn, "USE DATABASE mydatabase.sqlite;");

    // compile the SQL statement
    SQCloudVM *vm = SQCloudVMCompile(conn, "SELECT * FROM table1 LIMIT1;", -1, NULL);

    // execute the query

    // count the number of columns
    int count = SQCloudVMColumnCount(vm);

    // ...