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 6654685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:25:08+00:00 2026-05-26T01:25:08+00:00

How can I create a local database inside a Microsoft Visual C++ 2010 Express

  • 0

How can I create a local database inside a Microsoft Visual C++ 2010 Express project?

I can’t find this simple answer in the web. The only answer I’ve found is for Visual Studio: using project > add new item > local database. But this option isn’t available in Visual c++ 2010 Express edition.

I tried installing "Microsoft SQL Server Compact 4" and "Microsoft SQL Server Denali", and updating "Microsoft Visual C++ 2010 Express" from "Windows Update".

  • 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-26T01:25:09+00:00Added an answer on May 26, 2026 at 1:25 am

    Ok, I got a solution at last. Regrettably I must answer my own question…

    I used SQLite library (http://www.sqlite.org/). It was a little complicated because the sqlite documentation is a bit vague, but I did as follows:

    • Download sqlitedll*.zip – extract .def and .dll files somewhere.
    • Generate the lib file with a command like “c:\program
      files\micros~1\vc98\bin\lib” /def:sqlite3.def”. Do that from a command
      prompt, in the directory with the .def file in, with the appropriate
      path to your lib.exe. You may need to run vcvars32.bat first, which is
      also in the bin directory. Copy the resulting .lib to an appropriate
      place, and set that as a library directory in VC++. (Or do it on a
      per-project basis.)
    • Download the sqlite-source*.zip file, and extract the sqlite3.h file
      from within to a suitable directory. Set that as an include directory
      in VC++. (Again, you could do it on a per-project basis.)
    • In your project, #include as required, add sqlite3.lib
      to your project, copy the sqlite3.dll to your executable’s directory
      or working directory, and you should be ready to go.

    Then, is easy to use no-out queries, but if you want to use a SQL “SELECT” for example, you could use this code:

    std::string queries;
    // A prepered statement for fetching tables
    sqlite3_stmt *stmt;
    // Create a handle for database connection, create a pointer to sqlite3
    sqlite3 *handle;
    // try to create the database. If it doesnt exist, it would be created
    // pass a pointer to the pointer to sqlite3, in short sqlite3**
    int retval = sqlite3_open("local.db",&handle);
    // If connection failed, handle returns NULL
    if(retval){
        System::Windows::Forms::MessageBox::Show("Database connection failed");
        return;
    }       
    // Create the SQL query for creating a table
    char create_table[100] = "CREATE TABLE IF NOT EXISTS users (uname TEXT PRIMARY KEY,pass TEXT NOT NULL,activated INTEGER)";
    // Execute the query for creating the table
    retval = sqlite3_exec(handle,create_table,0,0,0);
    // Insert first row and second row
    queries = "INSERT INTO users VALUES('manish','manish',1)";
    retval = sqlite3_exec(handle,queries.c_str(),0,0,0);
    queries = "INSERT INTO users VALUES('mehul','pulsar',0)";
    retval = sqlite3_exec(handle,queries.c_str(),0,0,0);
    // select those rows from the table
    queries = "SELECT * from users";
    retval = sqlite3_prepare_v2(handle,queries.c_str(),-1,&stmt,0);
    if(retval){
        System::Windows::Forms::MessageBox::Show("Selecting data from DB Failed");
        return ;
    }
    // Read the number of rows fetched
    int cols = sqlite3_column_count(stmt);
    while(1){
        // fetch a row’s status
        retval = sqlite3_step(stmt);
        if(retval == SQLITE_ROW){
        // SQLITE_ROW means fetched a row
        // sqlite3_column_text returns a const void* , typecast it to const char*
            for(int col=0 ; col<cols;col++){
                const char *val = (const char*)sqlite3_column_text(stmt,col);
                System::Windows::Forms::MessageBox::Show(stdstr2systemstr(sqlite3_column_name(stmt,col))+" = "+stdstr2systemstr(val));
            }
        }
        else
        if(retval == SQLITE_DONE){
                // All rows finished
                System::Windows::Forms::MessageBox::Show("All rows fetched");
                break;
            }
            else{
                // Some error encountered
                System::Windows::Forms::MessageBox::Show("Some error encountered");
                return ;
            }
        }
        // Close the handle to free memory
        sqlite3_close(handle);
    

    I expect this info be useful!

    Sources:

    • http://www.gamedev.net/topic/332251-sqlite3-and-visual-c/page_p_3157685#entry3157685
    • http://milky.manishsinha.net/2009/03/30/sqlite-with-c/
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create directories in the local machine, can i do this with
I'm trying to create a local database for a Windows Phone application. I can
How can I create a local user account using .NET 2.0 and c# and
I can connect to remote SQL Server database and I want to create a
I'm very frustrated. I have a website running on Visual Web Developer 2008 Express
Need example how to create new local database and a connection string, if possible
By default, when you create a local database cache using the wizard provided by
I'm working on a project in Visual Studio, and I want to create a
I am using the web kit browsers local database to temporarily store some data
I create SQL CE 3.5 database dynamically in asp.net webservice. I can create tables,

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.