Re: [sqlite] Need help To Get Started with SQLITE

2009-10-03 Thread jack
Thanks. Obviously it's going to take awhile to remember my C.

Jack

- Original Message - 
From: "Dan Kennedy" <danielk1...@gmail.com>
To: "General Discussion of SQLite Database" <sqlite-users@sqlite.org>
Sent: Saturday, October 03, 2009 1:05 PM
Subject: Re: [sqlite] Need help To Get Started with SQLITE


> 
> On Oct 4, 2009, at 12:01 AM, jack wrote:
> 
>> I just setting out to learn how to use sqlite3 (3.6.18).  Obviouly  
>> I'm missing some very important points.
>>
>> The very simple test app below is to  open (and create) an sql  
>> datbase then close it
>>
>> Using windows XP. Using a precompiled .LIB. I confirmed the version  
>> number from the command line.
>>
>> It bombs!
>>
>> #include 
>> #include "sqlite3.h"
>> int main()
>> {
>> using namespace std;
>> std::string dbName = "C:\\SQL DATABASES\\first_try.db";
>> const char * c_dbName = dbName.c_str();
>> sqlite3  **db;
>> int  rc;
>>
>> rc = sqlite3_open( "X", db );
> 
> The above causes SQLite to dereference pointer db, which is  
> uninitialized.
> You want something like:
> 
>   sqlite3 *db;
>   sqlite3_open("X", );
>   ...
>   sqlite3_close(db);
> 
> 
> 
> 
>> sqlite3_close( *db );
>> return 0;
>> }
>>
>>
>> I tracked down in sqlite3.c where it bombed.
>>
>> #if !SQLITE_OS_WINCE && !defined(__CYGWIN__)
>>  int nByte;
>>  void *zConverted;
>>  char *zOut;
>>  UNUSED_PARAMETER(nFull);
>>  zConverted = convertUtf8Filename(zRelative);
>>  if( isNT() ){
>>WCHAR *zTemp;
>>nByte = GetFullPathNameW((WCHAR*)zConverted, 0, 0, 0) + 3;
>>zTemp = malloc( nByte*sizeof(zTemp[0]) );
>>if( zTemp==0 ){
>>  free(zConverted);
>>  return SQLITE_NOMEM;   <<<<<*** GOT TO HERE THEN BOMBED
>>}
>>GetFullPathNameW((WCHAR*)zConverted, nByte, zTemp, 0);
>>free(zConverted);
>>zOut = unicodeToUtf8(zTemp);
>>free(zTemp);
>>
>>
>> Jack
>>
>> ___
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Need help To Get Started with SQLITE

2009-10-03 Thread Dan Kennedy

On Oct 4, 2009, at 12:01 AM, jack wrote:

> I just setting out to learn how to use sqlite3 (3.6.18).  Obviouly  
> I'm missing some very important points.
>
> The very simple test app below is to  open (and create) an sql  
> datbase then close it
>
> Using windows XP. Using a precompiled .LIB. I confirmed the version  
> number from the command line.
>
> It bombs!
>
> #include 
> #include "sqlite3.h"
> int main()
> {
> using namespace std;
> std::string dbName = "C:\\SQL DATABASES\\first_try.db";
> const char * c_dbName = dbName.c_str();
> sqlite3  **db;
> int  rc;
>
> rc = sqlite3_open( "X", db );

The above causes SQLite to dereference pointer db, which is  
uninitialized.
You want something like:

   sqlite3 *db;
   sqlite3_open("X", );
   ...
   sqlite3_close(db);




> sqlite3_close( *db );
> return 0;
> }
>
>
> I tracked down in sqlite3.c where it bombed.
>
> #if !SQLITE_OS_WINCE && !defined(__CYGWIN__)
>  int nByte;
>  void *zConverted;
>  char *zOut;
>  UNUSED_PARAMETER(nFull);
>  zConverted = convertUtf8Filename(zRelative);
>  if( isNT() ){
>WCHAR *zTemp;
>nByte = GetFullPathNameW((WCHAR*)zConverted, 0, 0, 0) + 3;
>zTemp = malloc( nByte*sizeof(zTemp[0]) );
>if( zTemp==0 ){
>  free(zConverted);
>  return SQLITE_NOMEM;   <*** GOT TO HERE THEN BOMBED
>}
>GetFullPathNameW((WCHAR*)zConverted, nByte, zTemp, 0);
>free(zConverted);
>zOut = unicodeToUtf8(zTemp);
>free(zTemp);
>
>
> Jack
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users