in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

Sample Code

Last post 11-11-2011 3:32 AM by aimeepitt. 13 replies.
Page 1 of 1 (14 items)
Sort Posts: Previous Next
  • 11-21-2005 8:19 AM

    Sample Code

    Locked Reply Contact
    After some thought, I decided that rather than do some really rudimentary tutorial code that demonstrates the simplest of SQL, my time would be better spent hitting on some of the more advanced topics and features of SQLite.  Here are some of the samples I hope to complete in the coming days: 
    1. Creating a new SQLite database file
    2. Enabling NTFS file compression on a database file
    3. Enabling NTFS encrypted file system support on a database file (obsolete, see #5)
    4. Writing parameterized queries
    5. Encrypting, decrypting and attaching to encrypted databases
    6. Writing high performance inserts/updates
    7. User-defined scalar, aggregate and collation functions
    8. Attaching multiple databases to a connection (aka "how to read and write simultaneously")
    9. Reclaiming unused space in a database file (vacuum)
    10. Retrieving and interpreting schema information

     

  • 12-02-2005 2:41 PM In reply to

    • Joe
    • Not Ranked
    • Joined on 12-02-2005
    • Posts 1

    Re: Sample Code

    RS,
    Your How To's are very helpful. Thank you for your time.
    Do you know when you're going to be able to write 5 - 9 from your list?
    Alternatively do you know of other good sources for high performance database programing?
     
    Thank you,
    Joe
  • 12-02-2005 2:52 PM In reply to

    Re: Sample Code

    I'll be finishing those up next week if I'm able.  Things are getting a little crazy with the holidays coming up!

    Robert

     

  • 03-21-2006 7:03 AM In reply to

    Re: Sample Code

    Robert,

    great job! it works wery nice and i love the performance.

    I think other people will also agree that it would be great if you can make PDF manual which will come together with installation of ado.net sqlite.

    grtz

    Perica

  • 03-15-2007 4:45 PM In reply to

    Re: Sample Code

    So its been 1 year so far, and I still dont see an example of user defined functions.  This would be extremely helpful for me.  Could you show us a quick example of this?  Whenever I try it I get a no such function.
  • 03-27-2007 9:57 PM In reply to

    • Wiaz
    • Top 25 Contributor
    • Joined on 01-11-2007
    • Poland
    • Posts 47

    Re: Sample Code

    It was easy to find anexample of user function. Here is link to thread about adding regex function to sqlite:
    http://sqlite.phxsoftware.com/forums/thread/1457.aspx
    Wiaz
  • 03-30-2007 8:45 AM In reply to

    Re: Sample Code

    In the source code distribution is a project called Test.  Inside that project is TestCases.cs which contains several examples of user-defined scalar and aggregate functions and collating sequences.

    Robert

     

  • 11-25-2008 3:30 PM In reply to

    Re: Sample Code

    Hi Does anyone know where I could find some examples written in VB.NET that would show how to use transactions to do bulk inserts? I am a n00b so please be gentle with me! Thanks!
  • 11-25-2008 4:00 PM In reply to

    Re: Sample Code

    Perhaps I should explain further. Below is sample code as provided in the sqlite.net help file. - I would ideally like to see this example written in VB,NET using (SQLiteTransaction mytransaction = myconnection.BeginTransaction()) { using (SQLiteCommand mycommand = new SQLiteCommand(myconnection)) { SQLiteParameter myparam = new SQLiteParameter(); int n; mycommand.CommandText = "INSERT INTO [MyTable] ([MyId]) VALUES(?)"; mycommand.Parameters.Add(myparam); for (n = 0; n
  • 11-26-2008 2:13 AM In reply to

    • Mark2
    • Top 10 Contributor
    • Joined on 04-24-2008
    • Posts 70

    VB.Net <-> C# conversion

    SharpDevelop is a free IDE for C# and VB.NET projects on Microsoft's .NET platform, you can download it at http://www.sharpdevelop.net.
    You can then paste the C# code into an empty project and under Tools -> Convert Code to -> VB.NET let the IDE convert the code for you, VB.NET -> C# is also possible. Your sample is converted to:

             Using mytransaction As SQLiteTransaction = myconnection.BeginTransaction()
                    Using mycommand As New SQLiteCommand(myconnection)
                        Dim myparam As New SQLiteParameter()
                        Dim n As Integer

                        mycommand.CommandText = "INSERT INTO [MyTable] ([MyId]) VALUES(?)"
                        mycommand.Parameters.Add(myparam)
                        For n = 0 To 99999

                            myparam.Value = n + 1
                            mycommand.ExecuteNonQuery()
                        Next
                    End Using
                    mytransaction.Commit()
                End Using

     

    Filed under: ,
  • 11-26-2008 1:44 PM In reply to

    Re: VB.Net <-> C# conversion

    Thanks - I think I am nearly there... This is my code: myConnection.Open() SqlCommand = myConnection.CreateCommand SQLcommand.CommandText = "CREATE TABLE ITEM1(id INTEGER PRIMARY KEY AUTOINCREMENT, Data integer);" SQLcommand.ExecuteNonQuery() Dim myTrans = myConnection.BeginTransaction() Using mytransaction As SQLiteTransaction = myConnection.BeginTransaction() Using mycommand As New SQLiteCommand(myConnection) Dim myparam As New SQLiteParameter() Dim n As Integer mycommand.CommandText = "INSERT INTO ITEM1 ([DATA]) VALUES(?)" mycommand.Parameters.Add(myparam) For n = 0 To 99999 myparam.Value = n + 1 mycommand.ExecuteNonQuery() Next End Using mytransaction.Commit() End Using myConnection.Close() It runs without error, but the table fails to be updated. Any ideas? Thanks !!
  • 03-14-2011 8:39 AM In reply to

    Re: VB.Net <-> C# conversion

    Thanks
    My opinion concerning the creating of different essays and compositions is not good, because I oft have problems with it. Possibly I am inattentive or I haven’t big talent for it. I recognize it is better for me to apply essential assistance of writers onlines. The ordered works are good and without mistakes.
  • 06-20-2011 5:55 PM In reply to

    Re: VB.Net <-> C# conversion

    This really helped me a lot!:D
  • 11-11-2011 3:32 AM In reply to

    Re: Sample Code

     SEE i.e. the SQLite Encryption Extension which allows an application to read and write encrypted database files. This aapplication use the 'Attach' command of SQLite talk to two or more encrypted and unencrypted database files. Every database file have its own encryption key.

Page 1 of 1 (14 items)
Powered by Community Server (Commercial Edition), by Telligent Systems