Click here to Skip to main content
Licence CPOL
First Posted 10 Mar 2007
Views 98,167
Downloads 2,527
Bookmarked 71 times

SQLite GUI

By | 10 Mar 2007 | Article
A GUI for SQLite in .NET
Screenshot - SQLiteGUI.gif

Introduction

This article describes how to create, insert, update SQLite database from GUI.

Description

SQLite GUI is a simple GUI for creating a new SQLite database and opening an existing SQLite database. It can also create, delete and update tables in the database. All the available tables in the database are shown. The records of various types including BLOB are displayed in the DataGridView. And the data in the DataGridView can be printed. The schema for all the available tables is displayed.

Dependencies

The SQLite.NET assembly is available here. Add the reference SQLite.Net.dll to the project and use the namespace Finisar.SQLite to work with SQLite.

Finisar.SQLite

Finisar.SQLite is an ADO.NET Data Provider for accessing SQLite-Databases using the .NET-Framework. In SQLite, a complete database is stored in a single disk file. SQLite is zero-configuration - no setup or administration needed. SQLite itself is "a small C library that implements a self-contained, embeddable, zero-configuration SQL database engine" (quoted from the sqlite.org Website). The Finisar.SQLite Data Provider is an easy way to use the SQLite-Database in .NET languages like C# and VB.NET.

Sample Code

try
{
      //Connection string 
      string connString = String.Format("Data Source={0};New=False;Version=3", DB_NAME);
      
      //Connecting database
      SQLiteConnection sqlconn = new SQLiteConnection(connString);
      
      //Open the connection
      sqlconn.Open();

      //Query
      string CommandText = "Select name from sqlite_master;";

      //SQLiteDataAdapter to fill the DataSet
      SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter(CommandText, sqlconn);
      dataAdapter.Fill(ds);

      //Get the collection of rows from the DataSet
      DataRowCollection dataRowCol = ds.Tables[0].Rows;

      //Add the tables available in the DB to the combo box
      foreach (DataRow dr in dataRowCol)
      {
          tablecombobox.Items.Add(dr["name"]);
      }
      
      //Close the Connection
      sqlconn.Close();

}              
catch (SQLiteException sqlex)
{
    MessageBox.Show(sqlex.Message);
}

To Do

Update cannot be performed on table without primary key. The SelectCommand must also return at least one primary key or unique column. If none are present, an InvalidOperation exception is generated, and the commands are not generated. The alternative way is create select, insert and update command for that particular table. Refer to MSDN. It will be available in the next version of SQLite GUI.

History

  • 10th March, 2007: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Udhaya Kumar.D

Engineer

India India

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralWindows 7 Pinmemberjimmygyuma10:49 13 Nov '09  
GeneralRe: Windows 7 Pinmemberkazmirci21:39 23 Dec '09  
GeneralExcellent Pinmemberloyal ginger6:11 6 Oct '09  
GeneralRe: Excellent PinmemberUdhaya Kumar.D22:53 22 Nov '09  
GeneralUpdate problem Pinmemberjimmygyuma7:38 13 Jun '09  
GeneralProblem PinmemberZergushonok5:49 28 Oct '08  
GeneralRe: Problem PinmemberUdhaya Kumar.D6:23 4 May '09  
QuestionReadonly Mode Pinmembercawoodm9:49 17 Sep '08  
AnswerRe: Readonly Mode PinmemberUdhaya Kumar.D5:25 30 Sep '08  
GeneralPassword Protection PinmemberH0G4N9:09 3 Dec '07  
Generaluse System.Data.SQLite in the program PinmemberVirusCamp20:33 12 Jun '07  
GeneralRe: use System.Data.SQLite in the program PinmemberVirusCamp20:42 12 Jun '07  
GeneralA little problem Pinmembernemopeti23:12 24 Mar '07  
Hi!
 
Iam intrested in managing sqlite databases, and I happy to see your implementation, but I have a problem, when try to open a database.
Get error:
Unable to load DLL "sqlite3" HRESULT 0x8007007E
 
How can I fox this please?
 
Thanks!
GeneralRe: A little problem PinmemberUdhaya Kumar.D21:55 25 Mar '07  
GeneralRe: A little problem [modified] PinmemberMad_Mike4:31 10 Apr '07  
GeneralRe: A little problem Pinmemberstuttgart12:16 28 Sep '07  
GeneralYou can get sqllite3.dll at sqllite.org Pinmemberwombleme4:25 5 Oct '10  
GeneralSimple to the point Pinmemberspoodygoon10:38 10 Mar '07  
GeneralSimilar project PinmemberGeorge_Saveliev4:36 10 Mar '07  
NewsRe: Similar project PinmemberAndré Ziegler7:10 10 Mar '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120529.1 | Last Updated 10 Mar 2007
Article Copyright 2007 by Udhaya Kumar.D
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid