Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WinCE + ATL + SQLite = ???

Status
Not open for further replies.

k1Ll5w1tcH

Programmer
Jul 29, 2008
9
ZA
Hi

Posted in the ATL forum, but it seems like there hasn't been activity for a while.

Can someone please steer me in the right direction. I'm trying to create a Windows CE ATL dll with SQLite database connectivity.

I've got the Windows CE part working and the ATL(well kinda), but am having trouble with sqlite.

If anyone can share some sample code and links to a sqlite wrapper for Windows CE, if any?

Much appreciated :)
 
This works for normal Windows - it may work with CE. It basically selects all entries from the table users. It doesn't use ATL since sqlite is just C code.
Code:
//!!@@ Step 1 include sqlite header
#include "sqlite/sqlite3.h"
#include <iostream>

int main ()
{
   //!!@@ Step 2 - declare db handle and open database
   sqlite3* db;
   int res;
   res = sqlite3_open ("test.s3db", &db);
   std::cout << "open " << res << std::endl;

   //!!@@ Step 3 - list contents of a table
   int nrow, ncol;
   char** dbresult;
   char* errmsg;

   res = sqlite3_get_table (
      db,
      "SELECT * FROM users",
      &dbresult,
      &nrow,
      &ncol,
      &errmsg);

   //!!@@ Step 4 - check the results
   if (res == SQLITE_OK)
   {
      for (int rr = 0; rr < nrow; ++rr)
      {
         for (int cc = 0; cc < ncol; ++cc)
         {
            std::cout << dbresult[rr * ncol + cc] << "\t";
         }
         std::cout << std::endl;
      }
   }

   //!!@@ Step 5 free the results
   sqlite3_free_table (dbresult);

   //!!@@ Step 6 Close the table
   res = sqlite3_close(db);
   std::cout << "close" << res << std::endl;
   return 0;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top