Originally, the project was created with _tmain, rather than main. Despite
the character set being set to 'Not Set', changing it to main fixed the
problem in the console app. It now returns with '0', so thanks! I've not
seen _tmain before, and presume it's just a macro.

So I wonder whether the library is still using the wrong character set,
despite being set to 'Not set' too. I've moved the project to Visual Studio
2010, and it works better now.

The database is now being created fine, but with the same error on the Exec
statement. However, I need to check the data being passed from Fortran to
this library, as I strongly suspect the problem now is down to the
character encoding (I believe the data needs to be changed slightly to have
a null terminator as the last character).


 #include "sqlite3.h"
#include <windows.h>
#include <atlstr.h>
#include <atlbase.h>
extern "C"
{
 void EXECUTESQL(char *dataBase, char *query, int returnValue)
 {
  // Create the object
  sqlite3 *oDatabase;
  // Create the error objects
  char *sErrorMessage;
  // Open/create the table, if required
  returnValue = sqlite3_open_v2("C:/Newfolder/testing.db", &oDatabase,
SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, NULL);
  if (returnValue != SQLITE_OK )
  {
   //sqlite3_close(oDatabase);
   CString t;
   t.Format(_T("%d"), returnValue);
   MessageBoxA(NULL, t, "Error", MB_OK);
   MessageBoxA(NULL, sqlite3_errstr(returnValue), "SQL Open4 Error", MB_OK);
   return;
  }
  // Run the query
  returnValue = sqlite3_exec(oDatabase, query, 0, 0, &sErrorMessage);
  if (returnValue != SQLITE_OK )
  {
   sqlite3_close(oDatabase);
   MessageBoxA(NULL, sqlite3_errstr(returnValue), "SQL Exec Error", MB_OK);
   return;
  }
  // Finish up
  sqlite3_close(oDatabase);
  return;
 }
}

Once again, thanks for the help. It was an odd issue. I'll compare the
projects and command line options between the old VS2012 project, and the
VS2010 project created today.

And I'll get checking the data being sent from fortran.


Rob.


On Fri, Apr 5, 2013 at 5:02 PM, Michael Black <mdblac...@yahoo.com> wrote:

> How about just posting your COMPLETE code example for your console app.
> Some of us can't import a VS2012 project
> I just sent you a complete example that works.  Are you saying this doesn't
> work for you?
>
> #include <stdio.h>
> #include "sqlite3.h"
>
> main()
> {
>   sqlite3 *oDatabase;
>   int returnValue;
>   returnValue = sqlite3_open_v2("D:/SQlite/testing.db", &oDatabase,
> SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, NULL);
>   if (returnValue != SQLITE_OK )
>   {
>     printf("%d: %s\n",returnValue,sqlite3_errmsg(oDatabase));
>   }
>   else {
>     printf("Got it\n");
>   }
> }
>
> -----Original Message-----
> From: sqlite-users-boun...@sqlite.org
> [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Rob Collie
> Sent: Friday, April 05, 2013 9:47 AM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] SQL Logic error or missing database
>
> Nothing seems to be overly weird, and the console app is a fresh project,
> with very little changed.
>
> I'm compiling under 32-bit in VS2012 using the amalgamation files. I can
> attach my test project if needed. I'm really rather curious to know what I
> broke.
>
>
> On Fri, Apr 5, 2013 at 4:28 PM, Noel Frankinet
> <noel.franki...@gmail.com>wrote:
>
> > it's time to check your compiler setting, anything weird ? Are you sure
> you
> > have the source code of sqlite for windows ? 32 or 64 bits settings ??
> >
> >
> > On 5 April 2013 16:24, Rob Collie <rob.col...@gmail.com> wrote:
> >
> > > Same problem, I'm afraid. I've tried just about every combination
> > suggested
> > > in http://www.sqlite.org/c3ref/open.html
> > >
> > >
> > > On Fri, Apr 5, 2013 at 4:18 PM, Kevin Benson <kevin.m.ben...@gmail.com
> > > >wrote:
> > >
> > > > On Fri, Apr 5, 2013 at 10:08 AM, Rob Collie <rob.col...@gmail.com>
> > > wrote:
> > > >
> > > > > Yeap, I'm on Visual Studio 2012. I've created a console app:
> > > > >
> > > > >
> > > > >  sqlite3 *oDatabase;
> > > > >  int returnValue;
> > > > >  returnValue = sqlite3_open_v2("file://C:/Newfolder/testing.db",
> > > > > & oDatabase, SQLITE_OPEN_CREATE, NULL);
> > > > >  if (returnValue != SQLITE_OK )
> > > > >  {
> > > > >   //sqlite3_close(oDatabase);
> > > > >   return returnValue ;
> > > > >  }
> > > > >  int anyKey;
> > > > >  return 0;
> > > > >
> > > > > It returns 21. Checking the other project, the open actually does
> > > return
> > > > 21
> > > > > too.
> > > > >
> > > >
> > > >
> > > > Three(3) forward slashes for the Internet path style in Windows,
> maybe?
> > > >
> > > > file:///C:/Newfolder/testing.db
> > > > --
> > > >    --
> > > >       --
> > > >          --Ô¿Ô--
> > > >         K e V i N
> > > > _______________________________________________
> > > > 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
> > >
> >
> >
> >
> > --
> > Noël Frankinet
> > Strategis sprl
> > 0478/90.92.54
> > _______________________________________________
> > 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
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to