Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6955829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:47:19+00:00 2026-05-27T14:47:19+00:00

I try to save a simpel struct (vector3) in the sqlite3_bind_blob but I have

  • 0

I try to save a simpel struct (vector3) in the sqlite3_bind_blob but I have no idea how this works. If I debug this code the console window crashes. How can i fix this problem?

struct vector3
{
    int X;
    int Y;
    int Z;
};

int main ()
{
    sqlite3 *db = NULL;
    sqlite3_stmt *res = NULL;   

    sqlite3_open_v2("SaveGame1.sav", &db, SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, NULL);

    string query = "CREATE TABLE IF NOT EXISTS TestPlayer (vector BLOB)";
    sqlite3_prepare_v2 (db, query.c_str(), query.length(), &res, 0);
    sqlite3_step(res);

    // Try to add mij struct
    vector3 MyLocation;
    MyLocation.X = 100;
    MyLocation.Y = 100;
    MyLocation.Z = 100;

    query = "INSERT INTO TestPlayer (location) VALUES (?);";
    sqlite3_prepare_v2 (db, query.c_str(), query.length(), &res, 0);

    sqlite3_bind_blob (res, 1, &MyLocation, sizeof(vector3), SQLITE_TRANSIENT);
    sqlite3_step(res);

    query = "SELECT * FROM TestPlayer;";
    sqlite3_prepare_v2 (db, query.c_str(), query.length(), &res, 0);
    sqlite3_step(res);

    const vector3 *GetLoc = (const vector3 *) sqlite3_column_blob(res, 0);

    cout << GetLoc->X << endl;

    sqlite3_finalize(res);
    sqlite3_close(db);

    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:47:20+00:00Added an answer on May 27, 2026 at 2:47 pm

    I believe that sqlite3_column_blob() must be used on the results of a query operation. Try issuing a query for the data that you just inserted

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

according to this image, i try to save data in NSUserDefaults but my App
I have been trying to figure out how all this validation works, but I
I have a POST controller action like: if (ModelState.IsValid) { try { //.. save
Ok, this seems simple but I can't find a solution to save my life.
OK, so I have this tiny little corner of my code where I'd like
When I try and save something to my list in SharePoint I get the
I try to create a new file inside a JSP and try to save
I try to create a form that can save a person's form data so
Try loading this normal .jpg file in Internet Explorer 6.0. I get an error
Try the following code public enum Color { Blue=1, Red=2, Green=3 } public List<Color>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.