Re: [sqlite] Dotnet C# support

2005-10-31 Thread Arjen Markus
Robert Simpson wrote:
> 
> That's exactly what I ended up doing in the ADO.NET 2.0 wrapper.  In order
> to implement full Compact Framework support and callbacks, I ended up
> writing stdcall entrypoints and callback wrappers for just about the entire
> SQLite API.
> 

My Fortran interface does something similar, I have done it that way to
hide
the gory (and platform-dependent) details of passing parameters of the
correct 
type to the SQLite C functions. On Windows I compile SQLite as a DLL -
that
takes care of the stdcall/cdecl issue.

Regards,

Arjen



Re: [sqlite] Dotnet C# support

2005-10-31 Thread Robert Simpson
That's exactly what I ended up doing in the ADO.NET 2.0 wrapper.  In order 
to implement full Compact Framework support and callbacks, I ended up 
writing stdcall entrypoints and callback wrappers for just about the entire 
SQLite API.


Robert


- Original Message - 
From: "Arjen Markus" <[EMAIL PROTECTED]>

To: <sqlite-users@sqlite.org>
Sent: Monday, October 31, 2005 12:28 AM
Subject: Re: [sqlite] Dotnet C# support



Robert Simpson wrote:






Lots of problems here ... My VB is rusty, but here goes:

1.  Don't bother declaring the callback struct -- you cannot do any form 
of
callbacks in .NET with SQLite without major hacking.  SQLite's callbacks 
are
expected to be "cdecl" and .NET callbacks are always "stdcall" and you 
will

get stack errors if you even attempt it.  The ADO.NET 2.0 provider for
SQLite does it, but I had to go through hoops.



Hm, this mismatch in calling convention could be solved by one or two
little wrapper
functions, couldn't it? I am not very familiar with .NET, so I could be
all wrong.

Regards,

Arjen






Re: [sqlite] Dotnet C# support

2005-10-30 Thread Arjen Markus
Robert Simpson wrote:
> 

> 
> Lots of problems here ... My VB is rusty, but here goes:
> 
> 1.  Don't bother declaring the callback struct -- you cannot do any form of
> callbacks in .NET with SQLite without major hacking.  SQLite's callbacks are
> expected to be "cdecl" and .NET callbacks are always "stdcall" and you will
> get stack errors if you even attempt it.  The ADO.NET 2.0 provider for
> SQLite does it, but I had to go through hoops.
> 

Hm, this mismatch in calling convention could be solved by one or two
little wrapper
functions, couldn't it? I am not very familiar with .NET, so I could be
all wrong.

Regards,

Arjen



Re: [sqlite] Dotnet C# support

2005-10-28 Thread Bert Verhees
I agree, never use PInvoke, if possible to avoid
There is a performqncepenalty, and maybe you loose platform-independency
(think of Mono)

Bert

> I think you are looking for this http://adodotnetsqlite.sourceforge.net/
>
> I wrote my own driver in C++ (boy, that was a lot of work) then discovered
> the above.
>
> -
> ed
>
> --- Wilfried Mestdagh <[EMAIL PROTECTED]> wrote:
>
>> Hi Darren,
>>
>> > Is there a version which will work for dotnot?
>>
>> If not then you can use every win32 dll in C# using P/Invoke
>>
>> ---
>> Rgds, Wilfried
>> http://www.mestdagh.biz
>>
>>
>
>
>
>
>
> __
> Yahoo! Mail - PC Magazine Editors' Choice 2005
> http://mail.yahoo.com
>




Re: [sqlite] Dotnet C# support

2005-10-28 Thread Edward Wilson
I think you are looking for this http://adodotnetsqlite.sourceforge.net/

I wrote my own driver in C++ (boy, that was a lot of work) then discovered the 
above.

-
ed

--- Wilfried Mestdagh <[EMAIL PROTECTED]> wrote:

> Hi Darren,
> 
> > Is there a version which will work for dotnot?
> 
> If not then you can use every win32 dll in C# using P/Invoke
> 
> ---
> Rgds, Wilfried
> http://www.mestdagh.biz
> 
> 





__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


Re: [sqlite] Dotnet C# support

2005-10-28 Thread Gregory Letellier

thx for your response !!


Robert Simpson a écrit :

- Original Message - From: "Gregory Letellier" 
<[EMAIL PROTECTED]>




i'm trying tu use sqli3 with vb. net
he create the db but not the table..
what is the mistake ?

i've this code

Imports System.Runtime.InteropServices

Public Class Form1

    _
   Public Structure sqlite_callback
   Public Void As Long
   Public I1 As Long
   Public s1 As String
   Public s2 As String
   End Structure

   Public Declare Function sqlite3_open Lib "sqlite3.dll" (ByVal
Filename As String, ByRef Handle As Long) As Long
   Public Declare Function sqlite3_exec Lib "sqlite3.dll" (ByVal Handle
As Long, ByVal Query As String, ByRef CallbackFunction As
sqlite_callback, ByRef CallBackArgs As Long, ByRef Erreur As String) 
As Long

   Public Declare Function sqlite3_close Lib "sqlite3.dll" (ByVal
Handle As Long) As Long
   Public Declare Function sqlite3_errmsg Lib "sqlite3.dll" (ByVal
Handle As Long) As String

   Public Sub Main()

   Dim lRet As Long
   Dim lHandle As Long
   Dim sErreur As String
   Dim sSQL As String

   lRet = sqlite3_open("c:\test.db", lHandle)

   sSQL = "CREATE Table Toto(titi varchar(15));"
   lRet = sqlite3_exec(lHandle, sSQL, Nothing, Nothing, sErreur)

   sqlite3_close(lHandle)
   End Sub
End Class



Lots of problems here ... My VB is rusty, but here goes:

1.  Don't bother declaring the callback struct -- you cannot do any 
form of callbacks in .NET with SQLite without major hacking.  SQLite's 
callbacks are expected to be "cdecl" and .NET callbacks are always 
"stdcall" and you will get stack errors if you even attempt it.  The 
ADO.NET 2.0 provider for SQLite does it, but I had to go through hoops.


2.  sqlite3_exec is declared incorrectly.  The errormessage is a char 
**, which is a pointer to a pointer.  Getting this out of sqlite into 
.NET is not straightforward.  You'll have to use ByRef IntPtr and use 
the Marshal class to convert it to a string.


3.  sqlite3_open and sqlite3_exec are both sortof declared and 
processed incorrectly.  Those functions expect UTF-8 encoded strings, 
and you are passing "string" to them which .NET will at best translate 
to MBCS ANSI strings -- which means no international support.  For 
added safety you should declare those API functions with the 
CharSet=ANSI attribute to make absolutely sure .NET gives sqlite ANSI 
strings instead of UNICODE strings. It's still wrong, but its close 
enough for English-only.


4.  All sqlite API functions are declared as cdecl, and without 
instructions to the contrary, .NET will try and call them as stdcall 
which means after every call .NET will have to perform stack fixups.  
It won't error out your program per-se, but it will be a performance 
hit.  There's an attribute you can use to change the calling 
conventions of the API declaration, but I can't remember it off the 
top of my head.


Robert






Re: [sqlite] Dotnet C# support

2005-10-28 Thread Robert Simpson
- Original Message - 
From: "Gregory Letellier" <[EMAIL PROTECTED]>




i'm trying tu use sqli3 with vb. net
he create the db but not the table..
what is the mistake ?

i've this code

Imports System.Runtime.InteropServices

Public Class Form1

    _
   Public Structure sqlite_callback
   Public Void As Long
   Public I1 As Long
   Public s1 As String
   Public s2 As String
   End Structure

   Public Declare Function sqlite3_open Lib "sqlite3.dll" (ByVal
Filename As String, ByRef Handle As Long) As Long
   Public Declare Function sqlite3_exec Lib "sqlite3.dll" (ByVal Handle
As Long, ByVal Query As String, ByRef CallbackFunction As
sqlite_callback, ByRef CallBackArgs As Long, ByRef Erreur As String) As 
Long

   Public Declare Function sqlite3_close Lib "sqlite3.dll" (ByVal
Handle As Long) As Long
   Public Declare Function sqlite3_errmsg Lib "sqlite3.dll" (ByVal
Handle As Long) As String

   Public Sub Main()

   Dim lRet As Long
   Dim lHandle As Long
   Dim sErreur As String
   Dim sSQL As String

   lRet = sqlite3_open("c:\test.db", lHandle)

   sSQL = "CREATE Table Toto(titi varchar(15));"
   lRet = sqlite3_exec(lHandle, sSQL, Nothing, Nothing, sErreur)

   sqlite3_close(lHandle)
   End Sub
End Class



Lots of problems here ... My VB is rusty, but here goes:

1.  Don't bother declaring the callback struct -- you cannot do any form of 
callbacks in .NET with SQLite without major hacking.  SQLite's callbacks are 
expected to be "cdecl" and .NET callbacks are always "stdcall" and you will 
get stack errors if you even attempt it.  The ADO.NET 2.0 provider for 
SQLite does it, but I had to go through hoops.


2.  sqlite3_exec is declared incorrectly.  The errormessage is a char **, 
which is a pointer to a pointer.  Getting this out of sqlite into .NET is 
not straightforward.  You'll have to use ByRef IntPtr and use the Marshal 
class to convert it to a string.


3.  sqlite3_open and sqlite3_exec are both sortof declared and processed 
incorrectly.  Those functions expect UTF-8 encoded strings, and you are 
passing "string" to them which .NET will at best translate to MBCS ANSI 
strings -- which means no international support.  For added safety you 
should declare those API functions with the CharSet=ANSI attribute to make 
absolutely sure .NET gives sqlite ANSI strings instead of UNICODE strings. 
It's still wrong, but its close enough for English-only.


4.  All sqlite API functions are declared as cdecl, and without instructions 
to the contrary, .NET will try and call them as stdcall which means after 
every call .NET will have to perform stack fixups.  It won't error out your 
program per-se, but it will be a performance hit.  There's an attribute you 
can use to change the calling conventions of the API declaration, but I 
can't remember it off the top of my head.


Robert




Re: [sqlite] Dotnet C# support

2005-10-28 Thread Robert Simpson
- Original Message - 
From: "Darren Lodge" <[EMAIL PROTECTED]>



Hi there,

Is there a version which will work for dotnot?



The WIKI page is the best place to look ... There are probably half a dozen 
providers for SQLite.  Two ADO.NET providers (for ADO.NET 1.1 and ADO.NET 
2.0) and several non-ADO.NET providers designed to be more streamlined.


Robert




RE: [sqlite] Dotnet C# support

2005-10-28 Thread Reid Thompson
Original Message
From: Darren Lodge [mailto:[EMAIL PROTECTED]
Sent: Friday, October 28, 2005 4:01 AM
To: sqlite-users@sqlite.org
Subject: [sqlite] Dotnet C# support

> Hi there,
> 
> Is there a version which will work for dotnot?
> 
> Darren Lodge
> Software Engineer
> CAP
> 
> 0113 222 2058 (direct)
> 0113 222 2000 (switchboard)
> 0113 222 2001 (fax)

http://docs.codehaus.org/display/BOO/SQLite+Database

reid


RE: [sqlite] Dotnet C# support

2005-10-28 Thread Reid Thompson
Original Message
From: Darren Lodge [mailto:[EMAIL PROTECTED]
Sent: Friday, October 28, 2005 4:01 AM
To: sqlite-users@sqlite.org
Subject: [sqlite] Dotnet C# support

> Hi there,
> 
> Is there a version which will work for dotnot?
> 
> Darren Lodge
> Software Engineer
> CAP
> 
> 0113 222 2058 (direct)
> 0113 222 2000 (switchboard)
> 0113 222 2001 (fax)

http://sourceforge.net/projects/adodotnetsqlite

http://www.phpguru.org/static/SQLite.NET.html

reid


Re: [sqlite] Dotnet C# support

2005-10-28 Thread Clay Dowling

Darren Lodge said:
> Hi there,
>
> Is there a version which will work for dotnot?

I've had good luck with some of the ADO.NET providers.  They work pretty
much like other ADO.NET providers.  It's been a year or more so I can't
say exactly how long ago it was, but I was reasonably happy with the
result.  Fair warning though that I'm not exactly a .NET power user, so
what was acceptable to me may be a steaming pile to you.

Clay Dowling
-- 
Simple Content Management
http://www.ceamus.com



Re: [sqlite] Dotnet C# support

2005-10-28 Thread Justin Greenwood
I've used the C# .net provider for SQLite quite a bit. You can use SQL3 
with these providers, you just have to add something to the connection 
string to tell the driver which version you're using and also the text 
encoding (UTF8Encoding=true;Version=3;). To create a new database, you 
just have to add the "New=True" key/value pair to the connection string. 
Here are some links to get you started:


Microsoft.Net 1.x ADO.Net Provider
http://sourceforge.net/projects/adodotnetsqlite

Here's some sample code:
---

SQLiteConnection Conn = new SQLiteConnection();
Conn.ConnectionString = "Data 
Source=diary.db;New=True;Compress=True;Synchronous=Off";

Conn.Open();

SQLiteCommand Cmd = new SQLiteCommand();
Cmd = Conn.CreateCommand();
Cmd.CommandText = "CREATE TABLE GOALS(GOALS_ID integer primary key , 
CATEGORY varchar (50), PRIORITY integer , SUBJECT varchar (150) , 
DESCRIPTION varchar (500),START_DATE datetime , COMPLETION_DATE datetime)" ;

Cmd.ExecuteNonQuery();

Cmd.CommandText="CREATE TABLE NOTES (NOTES_ID integer primary key 
,NOTES_DATE datetime ,NOTES_TEXT varchar (8000) )";

Cmd.ExecuteNonQuery();

Cmd.CommandText =" CREATE TABLE REMINDERS (REMINDER_ID integer primary 
key ,REMINDER_DATE smalldatetime ,SUBJECT varchar (150) ,DESCRIPTION 
varchar (500) , ALARM1_DATE datetime ,ALARM2_DATE datetime ,ALARM3_DATE 
datetime ,EMAIL_ALARM bit )";

Cmd.ExecuteNonQuery();

Cmd.CommandText ="CREATE TABLE TODO ( TODO_ID integer primary 
key,CATEGORY varchar (20),PRIORITY int, PERCENT_COMPLETE float, 
START_DATE datetime ,END_DATE datetime , SUBJECT varchar (150) , DETAILS 
varchar (8000) ";

Cmd.ExecuteNonQuery();

Cmd.CommandText ="CREATE TABLE CATEGORIES (CATEGORY_ID INTEGER PRIMARY 
KEY,CATEGORY_NAME varchar (25))";

Cmd.ExecuteNonQuery();

Cmd.Dispose();
Conn.Close();
-

There is also a new .net 2.0 provider:

Microsoft.Net 2.0 ADO.Net Provider
http://sourceforge.net/projects/sqlite-dotnet2



Gregory Letellier wrote:


i'm trying tu use sqli3 with vb. net
he create the db but not the table..
what is the mistake ?

i've this code

Imports System.Runtime.InteropServices

Public Class Form1
 <StructLayout(LayoutKind.Sequential, 
CharSet:=CharSet.Ansi)> _

   Public Structure sqlite_callback
   Public Void As Long
   Public I1 As Long
   Public s1 As String
   Public s2 As String
   End Structure

   Public Declare Function sqlite3_open Lib "sqlite3.dll" (ByVal 
Filename As String, ByRef Handle As Long) As Long
   Public Declare Function sqlite3_exec Lib "sqlite3.dll" (ByVal 
Handle As Long, ByVal Query As String, ByRef CallbackFunction As 
sqlite_callback, ByRef CallBackArgs As Long, ByRef Erreur As String) 
As Long
   Public Declare Function sqlite3_close Lib "sqlite3.dll" (ByVal 
Handle As Long) As Long
   Public Declare Function sqlite3_errmsg Lib "sqlite3.dll" (ByVal 
Handle As Long) As String

 Public Sub Main()

   Dim lRet As Long
   Dim lHandle As Long
   Dim sErreur As String
   Dim sSQL As String

   lRet = sqlite3_open("c:\test.db", lHandle)

   sSQL = "CREATE Table Toto(titi varchar(15));"
   lRet = sqlite3_exec(lHandle, sSQL, Nothing, Nothing, sErreur)
  sqlite3_close(lHandle)
   End Sub
End Class



Darren Lodge a écrit :


Thankyou!

Darren Lodge
Software Engineer
CAP

0113 222 2058 (direct)
0113 222 2000 (switchboard)
0113 222 2001 (fax)

-Original Message-
From: Peter Berkenbosch [mailto:[EMAIL PROTECTED] Sent: 28 October 
2005 09:19

To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Dotnet C# support

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Sigh..

http://www.google.com/search?hl=nl=SQLite+C%23=Google+zoeken
=


Darren Lodge wrote:
 


Hi there,

Is there a version which will work for dotnot?

Darren Lodge
Software Engineer
CAP

0113 222 2058 (direct)
0113 222 2000 (switchboard)
0113 222 2001 (fax)


  




- --
+---+--+
: Peter Berkenbosch:   :
:: t: +31 (0) 64 84 61653   :
: PeRo ICT Solutions: f: +31 (0) 84 22 09880   :
: Koemaad 26: m: [EMAIL PROTECTED] :
: 8431 TM Oosterwolde: w: www.pero-ict.nl   :
+---+--+
: OpenPGP 0x0F655F0D (random.sks.keyserver.penguin.de)   :
+--+





-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.1 (MingW32)

iD8DBQFDYd7g9bwznA9lXw0RAnb4AJ9oRUkvbXX5aX0HhXZEl6Lv4KNPyACgiUrq
yXTEUWDFVPk97iM5u14V1B4=
=0ECQ
-END PGP SIGNATURE-




 







Re: [sqlite] Dotnet C# support

2005-10-28 Thread Gregory Letellier

i'm trying tu use sqli3 with vb. net
he create the db but not the table..
what is the mistake ?

i've this code

Imports System.Runtime.InteropServices

Public Class Form1
  
   <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _

   Public Structure sqlite_callback
   Public Void As Long
   Public I1 As Long
   Public s1 As String
   Public s2 As String
   End Structure

   Public Declare Function sqlite3_open Lib "sqlite3.dll" (ByVal 
Filename As String, ByRef Handle As Long) As Long
   Public Declare Function sqlite3_exec Lib "sqlite3.dll" (ByVal Handle 
As Long, ByVal Query As String, ByRef CallbackFunction As 
sqlite_callback, ByRef CallBackArgs As Long, ByRef Erreur As String) As Long
   Public Declare Function sqlite3_close Lib "sqlite3.dll" (ByVal 
Handle As Long) As Long
   Public Declare Function sqlite3_errmsg Lib "sqlite3.dll" (ByVal 
Handle As Long) As String
  
   Public Sub Main()


   Dim lRet As Long
   Dim lHandle As Long
   Dim sErreur As String
   Dim sSQL As String

   lRet = sqlite3_open("c:\test.db", lHandle)

   sSQL = "CREATE Table Toto(titi varchar(15));"
   lRet = sqlite3_exec(lHandle, sSQL, Nothing, Nothing, sErreur)
   
   sqlite3_close(lHandle)

   End Sub
End Class



Darren Lodge a écrit :

Thankyou! 



Darren Lodge
Software Engineer
CAP

0113 222 2058 (direct)
0113 222 2000 (switchboard)
0113 222 2001 (fax)

-Original Message-
From: Peter Berkenbosch [mailto:[EMAIL PROTECTED] 
Sent: 28 October 2005 09:19

To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Dotnet C# support

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Sigh..

http://www.google.com/search?hl=nl=SQLite+C%23=Google+zoeken
=


Darren Lodge wrote:
 


Hi there,

Is there a version which will work for dotnot?

Darren Lodge
Software Engineer
CAP

0113 222 2058 (direct)
0113 222 2000 (switchboard)
0113 222 2001 (fax)


   




- --
+---+--+
: Peter Berkenbosch :  :
:   : t: +31 (0) 64 84 61653   :
: PeRo ICT Solutions: f: +31 (0) 84 22 09880   :
: Koemaad 26: m: [EMAIL PROTECTED] :
: 8431 TM Oosterwolde   : w: www.pero-ict.nl   :
+---+--+
: OpenPGP 0x0F655F0D (random.sks.keyserver.penguin.de) :
+--+





-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.1 (MingW32)

iD8DBQFDYd7g9bwznA9lXw0RAnb4AJ9oRUkvbXX5aX0HhXZEl6Lv4KNPyACgiUrq
yXTEUWDFVPk97iM5u14V1B4=
=0ECQ
-END PGP SIGNATURE-




 



RE: [sqlite] Dotnet C# support

2005-10-28 Thread Darren Lodge
Thankyou! 


Darren Lodge
Software Engineer
CAP
 
0113 222 2058 (direct)
0113 222 2000 (switchboard)
0113 222 2001 (fax)

-Original Message-
From: Peter Berkenbosch [mailto:[EMAIL PROTECTED] 
Sent: 28 October 2005 09:19
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Dotnet C# support

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Sigh..

http://www.google.com/search?hl=nl=SQLite+C%23=Google+zoeken
=


Darren Lodge wrote:
> Hi there,
>  
> Is there a version which will work for dotnot?
>  
> Darren Lodge
> Software Engineer
> CAP
>  
> 0113 222 2058 (direct)
> 0113 222 2000 (switchboard)
> 0113 222 2001 (fax)
>  
> 


- --
+---+--+
: Peter Berkenbosch :  :
:   : t: +31 (0) 64 84 61653   :
: PeRo ICT Solutions: f: +31 (0) 84 22 09880   :
: Koemaad 26: m: [EMAIL PROTECTED] :
: 8431 TM Oosterwolde   : w: www.pero-ict.nl   :
+---+--+
: OpenPGP 0x0F655F0D (random.sks.keyserver.penguin.de) :
+--+





-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.1 (MingW32)

iD8DBQFDYd7g9bwznA9lXw0RAnb4AJ9oRUkvbXX5aX0HhXZEl6Lv4KNPyACgiUrq
yXTEUWDFVPk97iM5u14V1B4=
=0ECQ
-END PGP SIGNATURE-




Re: [sqlite] Dotnet C# support

2005-10-28 Thread Peter Berkenbosch
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Sigh..

http://www.google.com/search?hl=nl=SQLite+C%23=Google+zoeken=


Darren Lodge wrote:
> Hi there,
>  
> Is there a version which will work for dotnot?
>  
> Darren Lodge
> Software Engineer
> CAP
>  
> 0113 222 2058 (direct)
> 0113 222 2000 (switchboard)
> 0113 222 2001 (fax)
>  
> 


- --
+---+--+
: Peter Berkenbosch :  :
:   : t: +31 (0) 64 84 61653   :
: PeRo ICT Solutions: f: +31 (0) 84 22 09880   :
: Koemaad 26: m: [EMAIL PROTECTED] :
: 8431 TM Oosterwolde   : w: www.pero-ict.nl   :
+---+--+
: OpenPGP 0x0F655F0D (random.sks.keyserver.penguin.de) :
+--+





-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.1 (MingW32)

iD8DBQFDYd7g9bwznA9lXw0RAnb4AJ9oRUkvbXX5aX0HhXZEl6Lv4KNPyACgiUrq
yXTEUWDFVPk97iM5u14V1B4=
=0ECQ
-END PGP SIGNATURE-


Re: [sqlite] Dotnet C# support

2005-10-28 Thread Wilfried Mestdagh
Hi Darren,

> Is there a version which will work for dotnot?

If not then you can use every win32 dll in C# using P/Invoke

---
Rgds, Wilfried
http://www.mestdagh.biz



[sqlite] Dotnet C# support

2005-10-28 Thread Darren Lodge
Hi there,
 
Is there a version which will work for dotnot?
 
Darren Lodge
Software Engineer
CAP
 
0113 222 2058 (direct)
0113 222 2000 (switchboard)
0113 222 2001 (fax)