Database
  Home arrow Database arrow Page 6 - Using SQLite for Simple Database Storage
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DATABASE

Using SQLite for Simple Database Storage
By: Clay Dowling
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 24
    2004-10-19

    Table of Contents:
  • Using SQLite for Simple Database Storage
  • SQLite in Action
  • An Example User Object
  • Saving a Record
  • Storing it in the Database
  • The Last Step

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using SQLite for Simple Database Storage - The Last Step


    (Page 6 of 6 )

    The last step which I haven't shown is the connection to the database.  Like other providers a connection string is necessary. Because the database is disk based rather than server based, the connection string is very different.  The following command connected to the database in my sample application:

    conn = New SQLiteConnection("Data Source=c:\accounts\user.db;Version=3")
    conn.Open()

    This is pretty much the minimal connection string necessary. Using an absolute path to the database is mandatory. When I tried to refer to a file in the application folder as a local file, the provider attempted to look for it in my systems folder. Likewise, if I excluded the version parameter the provider made random and inaccurate guesses as to the version of the database I was using.  Make sure to match this version number to the major version number of the client you use to create the database.

    Using SQLite on Windows requires slightly more administrative skill than on other platforms. During a transaction (such as an Insert or Update), the database changes are stored in a journal file until the entire transaction can be completed and written to the database. The web server process will need write access to the file, and permission to create files in the database directory. This permissions management can't be easily accomplished via an FTP connection, so you'll need console or remote desktop access to your web server. Keep this in mind if you're considering using SQLite in a hosted application environment.

    Getting SQLite

    SQLite is down-loadable from http://www.sqlite.org. The ADO.NET data provider I used can be downloaded from http://sourceforge.net/projects/adodotnetsqlite/. Other providers are available, including COM objects which can be used from traditional ASP pages.

    If your interest lies instead with desktop applications, SQLite is very easy to deploy. For Windows applications the engine is encapsulated in a DLL which must be distributed with your program.  No special configuration is needed to give access to the SQLite databases, so even including the library in a ZIP file with your executable will be sufficient for distribution. 


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Hello!Great article here. SQLite really is a simple, fast and powerful database...
       · Its a very helpful article...I have been looking for database designed with...
     

    DATABASE ARTICLES

    - Manage Projects with SQL Server Management S...
    - Query Editing and Regular Expressions with S...
    - Using SQL Server Management Studio Tools
    - SQL Server Management Studio
    - Exporting a MySQL Database to Excel Using OD...
    - Controlling Databases with SQL Server 2005 D...
    - Using Recovery Models with SQL Server 2005 D...
    - Handling Database Properties for the SQL Ser...
    - Managing Permissions with the SQL Server 200...
    - SQL Server 2005 Database Engine Security
    - Administering SQL Server 2005 Database Engine
    - Building Applications with Anonymous Types
    - A Closer Look at Anonymous Types
    - Programming with Anonymous Types
    - Converting Your Excel Worksheet into a Worki...





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek