Showing posts with label Database. Show all posts
Showing posts with label Database. Show all posts

Friday, October 26, 2012

A simple prize bond manager: old technology still works!

Introduction

The story begin with a simple problem, my father-in-law having some problem with his prize bonds. He has several prize bonds and each quarter government publish the prize bond lottery draw and he had to take each bond then go through the numbers. And it became hectic job for him.

Few days ago,  in a family dinner he told me about his problem, and asked me can I make a simple program so that his problem can be resolved. I kind of smiled and told him that I would be able to write something for him. Last weekend I sit and wrote some thing for him. Then I thought lets write an article about it, should be fun!.

My problems:

  1. It needs to be very simple.
  2. I can’t force him to use advance technology.
  3. Need to have some backup of data.
  4. Easy deployable.

It needs to be very simple

Decided to keep it very simple, so no login what so ever. One Main Screen where every thing is listed. A data add screen. And a simple match bond number screen to finding winning numbers. One interesting thing is that my father-in-law keep buying bonds for all the family members. so need to back up the data and ability to load backed up data.

I can’t force him to use advance technology

After little thought I decided to choose old technologies, because my client knows computer but i guess fancy advance technology might scare him off and my client will runway. And I believe it or not he use “windows xp” so what ever available with windows update.

Need to have some backup of data

Should be simple pretty simple steps to add delete and modify data. In case  user manage to screw thing up there should be a simple process with which he can backup the data and also restore data. Of course we have SQL Server and Enterprise manager to do that, but we don’t what clients to mange all those things. So I better use simple xml to generate back up.

Easy deployable

Important part, I don’t want to install anything in my pc beside the software, second the steps should be damn easy. kind of one client installer.

First thing First

Before writing any code I setup a open source project in github to keep my code. It’s a open source only because I want people to some how criticize me about my code and learn some thing out of it. Created my visual studio project. Now I have VS2012, and VS2010, I chose “VS2010” and as framework I chose “.net framework 2.0”.

Below the github project location is given. You guys can download and see what’s there if you want.

https://github.com/munnaonc/PrizeBondManager.git

Win forms 2.0 , .net framework 2.0 project

Alright, what ever I thought just gave me another shot to use some old technology, should be fun. After all the necessary code the solution explorer looks like the below screen shot.

image

Figure: Initial Project Structure in Solution explorer

To keep the data I have added a Microsoft SQL Server Compact Database also known as “.sdf” database named BondDB.sdf. Created a single table. In below screen shot the table structure is given.

image

Figure: Initial Project Structure in Solution explorer

For data retrieve and saving used one of the oldest technology that is typed dataset. Below screenshot gives you an idea of that work. In the dataset we have a custom query for the dataset named “GetDataBySerial” which returns the prize bond with serial number.

image

Figure: Initial Project Structure in Solution explorer

Wrapping Up the Coding

I added main feature as CRUD of Bonds, Backup Data, Load Data and of course Match a bond number, to find out if we have a winner or not. 

Without any user interface brush-up the application looks like the bellow screen shot. pretty bad right. We would make it presentable in future i guess, for the time being the idea is to get the application to my client quickly.

image

Figure: Main Application First Look

Data Layer codes for CRUD is given bellow

using System;
using System.Collections.Generic;
using System.Data;
using PrizeBonds.BondDBDataSetTableAdapters;

namespace PrizeBonds.Objects
{
public class DAL
{
public List<Bond> GetList()
{
var tBondTableAdapter = new t_bondTableAdapter();
var tBondDataTable = new BondDBDataSet.t_bondDataTable();
tBondTableAdapter.Fill(tBondDataTable);
var dataRows = tBondDataTable.Select();
return GetBonds(dataRows);
}

private static List<Bond> GetBonds(IEnumerable<DataRow> dataRows)
{
var bonds = new List<Bond>();
foreach (DataRow row in dataRows)
{
try
{
var bond = new Bond
{
Id = (Int64)row["ID"],
Serial = (Int64)row["Serial"],
Owner = row["Owner"].ToString(),
CreatedDate = (DateTime)row["CreatedDate"],
ModifiedDate = (DateTime)row["ModifiedDate"]
};
bonds.Add(bond);
}
catch (Exception exception)
{
exception.ToString();
}
}
return bonds;
}

public void AddBond(Bond bond)
{
var tBondTableAdapter = new t_bondTableAdapter();
tBondTableAdapter.Insert(bond.Serial, bond.Owner, bond.CreatedDate, bond.ModifiedDate);
}

public void DeleteBond(long id)
{
var tBondTableAdapter = new t_bondTableAdapter();
tBondTableAdapter.Delete(id);
}

public List<Bond> GetBondBySerial(long serial)
{
var tBondTableAdapter = new t_bondTableAdapter();
var bondDataTable = tBondTableAdapter.GetDataBySerial(serial);
if (bondDataTable.Rows.Count > 0)
{
return GetBonds(bondDataTable.Select());
}
return null;
}

public void UpdateBond(Bond bond)
{
var tBondTableAdapter = new t_bondTableAdapter();
var tBondDataTable = new BondDBDataSet.t_bondDataTable();
tBondTableAdapter.Fill(tBondDataTable);
var tBondRow = tBondDataTable.FindByID(bond.Id);
tBondRow.Owner = bond.Owner;
tBondRow.Serial = bond.Serial;
tBondRow.ModifiedDate = bond.ModifiedDate;
tBondTableAdapter.Update(tBondRow);
}
}
}


Created single object to manage and the application, named “bond”


using System;

namespace PrizeBonds.Objects
{
[Serializable]
public class Bond
{
public long Id { get; set; }
public long Serial { get; set; }
public string Owner { get; set; }
public DateTime CreatedDate { get; set; }
public DateTime ModifiedDate { get; set; }
}
}


 


Add, Update and match Bond serial


Below a very simple Add Bond window code is given. Its a win form window with tool window border style and displayed as a modal dialog.


image


same window is displayed with some property modified, to update the data also.


public void SetData(Bond dataBoundItem)
{
_updateBondCandidate = dataBoundItem;
txtOwner.Text = _updateBondCandidate.Owner;
txtSerial.Text = _updateBondCandidate.Serial.ToString(CultureInfo.InvariantCulture);
}


below the update window is given.


image


Below match bond window is given.


image


Code for Add update bond



private void UpdateBond()
{
_updateBondCandidate.Owner = txtOwner.Text;
_updateBondCandidate.Serial = Convert.ToInt64(txtSerial.Text);
_updateBondCandidate.ModifiedDate = DateTime.Now;

var dal = new DAL();
dal.UpdateBond(_updateBondCandidate);
this.Close();
}

private void AddNewBond()
{
var bond = new Bond
{
Serial = Convert.ToInt64(txtSerial.Text),
Owner = txtOwner.Text,
CreatedDate = DateTime.Now,
ModifiedDate = DateTime.Now
};
var dal = new DAL();
dal.AddBond(bond);
this.Close();
}






code for match bond


private void btnMatchBond_Click(object sender, EventArgs e)
{
if (ValidData())
{
var dal = new DAL();
var bonds = dal.GetBondBySerial(Convert.ToInt64(txtSerial.Text));
if (bonds == null)
{
lblMessage.Text = @"No match found!";
lblMessage.ForeColor = System.Drawing.Color.Red;
}
else
{
lblMessage.Text = @"Success! match found! You are a winner!";
lblMessage.ForeColor = System.Drawing.Color.Green;
}
}
}


private bool ValidData()
{
if (string.IsNullOrEmpty(txtSerial.Text))
{
ShowValidSerialMessage();
return false;
}
char[] charArray = txtSerial.Text.ToCharArray();
foreach (var val in charArray)
{
if (char.IsDigit(val) == false)
{
ShowValidSerialMessage();
return false;
}
}
if (txtSerial.Text.Length != 7)
{
ShowValidSerialMessage();
return false;
}
return true;
}

private void ShowValidSerialMessage()
{
MessageBox.Show(@"Please enter 7 digit valid Prize Bond Serial");
txtSerial.Focus();
}

private void btnCancel_Click(object sender, EventArgs e)
{
Close();
}

private void txtSerial_KeyPress(object sender, KeyPressEventArgs e)
{
char keyChar = e.KeyChar;
if (keyChar.Equals('\r'))
{
btnMatchBond_Click(sender,new EventArgs());
}
}



Save and Load Bond Data


For saving and loading data used old serialization concept. Below the code for saving and loading bond data is given.


using System.Windows.Forms;

namespace PrizeBonds.Objects
{
public class BackUpManager
{
public void LoadRule()
{

// Configure open file dialog box
var dlg = new OpenFileDialog { FileName = "Prize Bond Manager",
DefaultExt = ".pbm", Filter = @"Prize Bond Manager Files (.pbm)|*.pbm" };

// Show open file dialog box
var result = dlg.ShowDialog();

// Process open file dialog box results
if (result == DialogResult.OK)
{
// Open document
var filename = dlg.FileName;
var serializer = new Serializer();
var deSerializeObject = serializer.DeSerializeObject(filename);
var bonds = deSerializeObject.Bonds;
var dal = new DAL();
foreach (var bond in bonds)
{
dal.AddBond(bond);
}
}
}

public void SaveRule()
{
var dal = new DAL();
var bonds = dal.GetList();
if (bonds.Count == 0)
{
const string message = @"You do not have any bonds to Save, thus I am unable "
+ @" to save any bonds. Please add some bonds before Saving";
MessageBox.Show(message);
return;
}

var dlg = new SaveFileDialog { FileName = "Prize Bond Manager",
DefaultExt = ".pbm", Filter = @"Prize Bond Manager Files (.pbm)|*.pbm" };

// Show save file dialog box
var result = dlg.ShowDialog();

// Process save file dialog box results
if (result == DialogResult.OK)
{
// Save document
string filename = dlg.FileName;
var serializer = new Serializer();
var objectToSerialize = new ObjectToSerialize { Bonds = bonds };
serializer.SerializeObject(filename, objectToSerialize);
}
}
}
}



In future release I would try to improve the look and field of the application. since the purpose of the application is only to match and keep data. And of course the application will be used only in once a month so investing huge time to make it more stunning won't be  a good idea., but still will invest some amount of time.


Conclusion


In this short article we have built a small application for managing prize bond with some of the old technology exists in ms world. Hope you would like it. Please drop comment if you like it and don’t forget suggest me improvement tips.

Thursday, June 28, 2012

Using SQLite in Visual Studio 2010, with new and improved provider part1

Introduction

Almost a year ago I have written a blog post about SQLite with VS2010, and the old blog post can be found here, http://munnaondotnet.blogspot.com/2011/07/using-sqlite-in-visual-studio-2010.html. Lot of things has changed since then and its time to update the users and take everyone up to the speed. In fact may be all are up to the speed, I am the one who is doing the catch up any way, Previously the System.Data.SQLite provider was taken care by “http://sqlite.phxsoftware.com/” now SQLite.Org has taken the control of managing the provider and further development.

I have already listed a blog on who to install and the some features on on http://munnaondotnet.blogspot.com/2012/06/new-and-improved-systemdatasqlite-also.html and http://munnaondotnet.blogspot.com/2012/06/new-features-for-systemdatasqlite-build.html. in this blog I would simply show adding a data connection to Visual Studio 2010.

Adding the data connection

After installing the installation package if you open visual studio and click on Add connection it will simply lunch the following window.

image

Click on Change and this will again popup a new window like bellow dialog. You would see that there is a “System.Data.SQLite Database File”  option in Data Source List. Select the option and click ok.

image

After that you would get another option where you can either browse or create a new SQLite database file. For Now I have selected “New” and a file Open dialog box would popup where I have created a new SQLite database file, alternately you can also browse and choose your existing database file.

image

In the above window you can also choose to set password, for encryption and other necessary settings if you choose to have different setting rather than default.

For now we have the option to choose

  • Encoding
  • Date/Time Format
  • Synchronization

When you are done ok button will be enabled and click ok to add the connection.

image

Creating Tables And Views

WALAH! a SQLite data connection is been added in the data connections node of server explorer. Now its time to create a database table, the process is simple and just like the previous blog, right click on the Table node and you would see that there is a option says “Add New Table”, selecting the option will start the table designer, note that you would see a Warning message, fear not it just a bug reporting email address message.

image

while Creating the table  you would see that there is a huge set of database data type you have in SQLite, and almost everything is supported now including “nvarchar”. 

image

Alternately you can also create views and in conjunction with Table. Which is yet another great support. I am looking forward to get some Store procedure support in near future.

image

Conclusion

In this short article we have seen how we can use Visual Studio 2010 to edit and create a simple SQLite database, and from now on there is no need for another third-party SQLite database manager tool. Note that the support is only available in Standard or upper version of visual studio 2010, so no support in express editions, which is kind of bad for open source developers, but there is a licensing issue, so SQLite.Org has to go in this direction.

Hope to show some designer support option in next blog.  

Thursday, January 26, 2012

Installing Server and .net provider for firebird.

Today I am providing few simple screenshots to get a kick start on installing firebird and its .net provider.

Step 1: Download Firebird server or client package, if you are a windows user go to http://www.firebirdsql.org/en/server-packages/ and then download the 32 or 64 bit installation package.

image

Step 2: After downloading the correct version of your server package please lunch the installation wizard. You would see a screenshot like bellow.

image

Continue the installation process and when you see choosing service or Application choose application or server which ever suits your condition.

image

Finish the installation process and then move on to download the .net provider. Download and install the latest .net provider.

image

That’s it all set to move to next step you can develop application and use firebird as database. hit http://www.firebirdsql.org/en/net-examples-of-use/ to know more about how to use firebird in your .net code.

Hope this helps. Regards.

Thursday, January 5, 2012

Firebird a true open source database

I  Spent a lot of time online searching for a embedded database that can be used with any kind of application regardless of platform and technology. And you all can guess that SQLite is the best option for the purpose. But there are some other options as well for instance firebird.  This firebird has also server package and has sp and trigger facility with is a big plus. Bellow a short description is given and taken from there home site.

image

“Firebird is a relational database offering many ANSI SQL standard features that runs on Linux, Windows, and a variety of Unix platforms. Firebird offers excellent concurrency, high performance, and powerful language support for stored procedures and triggers. It has been used in production systems, under a variety of names, since 1981.
The Firebird Project is a commercially independent project of C and C++ programmers, technical advisors and supporters developing and enhancing a multi-platform relational database management system based on the source code released by Inprise Corp (now known as Borland Software Corp) on 25 July, 2000.
FREE LIKE A BIRD. Anyone can build a custom version of Firebird, as long as the modifications are made available, under the same IDPL licensing, for others to use and build on.
FREE LIKE FREE BEER. No fees for download, registration, licensing or deployment, even you distribute Firebird as part of your commercial software package.
Firebird's development depends on voluntary funding by people who benefit from using it. Funding options range from donations, through Firebird Foundation memberships to sponsorship commitments.
Choosing Firebird and saving or making money by your choice? Show your appreciation and encouragement by contributing money in proportion to these benefits.”

No database is popular unless you have good management studio and administration facility for developers as well as database administrators. But unfortunately after spending few minutes in google I found no good free management studio for it. “EMS SQL Manager for InterBase/Firebird” is a commercial and trial ware that can be used to administer that firebird database. Bello a screen shot is given.

image

But we can use ado.net provider and leverage visualstudio data feature to work with firebird easily. Hope to write more about firebird in future.

References

http://www.firebirdsql.org/en/start/#get-started

Thursday, August 25, 2011

Design SQL Server Compact Database with SQL Server management studio.

In previous section we have seen how we can use SQL Server Compact 4.0 Database. In this section we would see how we can create and edit and SQL Server Compact Database with SQL Server management studio. Lets start with SQL Server management studio, By default when you open the Management studio you would have two option for Server type and the options are follows

  • Database Engine
  • SQL Server Compact

We would select SQL Server Compact as our server type and click on database file combo, and it will bring up browse or create new option for the user. Select what ever suits your condition. For explanation I will choose create new for the time being.

image

After selecting the option you would get a dialog like the bellow screen shot. It is the database creation wizard. I am sure the options are pretty understandable to all. Browse and select the location where you wanted to create the database, if you have an existing database you can choose to override the existing database. Keep the destination Database Properties as follows. Next step is to provide a password for your database. you can choose to keep the password empty, in that case you would see a warning before created. Please choose the Encryption type and select ok. 

image

That’s it you would see a your database option created in object explorer and you are good to go for going ahead and design your database.

image

Let’s move ahead with the database table  creation wizard. The table creating wizard is pretty intuitive and a develop can easily understand. Right click on table node on object explorer and select new table option. Give a suitable name for your database table name, then fill the table columns, note that almost all the renowned data types are available, You can set you tables primary key from Primary key combo. And if you want to set the primary key as identity column just modify the column detail at bottom of the wizard and set Identity to True. Click ok to finish creating your table.

image

Next step is to create relationship among the tables. for this you have to right click on table note and select table properties. This will bring up your table property window. There are four sections of this window, we would concentrate on Add Relations for now. Click on add relation page, next fill primary key table and columns that you want to map, next give a name to the relation and click add columns, this will add relation columns to relation section. click ok to finish and close the dialog.

image

Now verify that the relation actually added by opening table properties for a table again and visit the Manage relation page on Table properties window. In Manage Relations page you will find your table relation ship in relation name combo. if you wish to modify or delete the relation, you can do it from this window.

image

Note that while creating database with SQL Server management studio you will eventually create a SQL Server Compact 3.5 database, we would talk about SQL Server Compact 4.0 in near future. Till then happy programming and best of luck.

Wednesday, August 24, 2011

Using SQL Server Compact 4.0 Local database with visual studio 2010

If we consider using Embedded database and the environment is Microsoft development platform, there are couple of choices.

  • SQL Server compact 4.0
  • SQLite 3.0
  • Firebird
  • Vista DB

There could be more options for embedded database but considering embedded database those four is most popular in the web. 

I have posted few blog post on how to use SQLite with visual studio to gain good amount of development ease. In this post we are going to see how to use SQL Server Compact 4.0 with Visual studio 2010. SQL Server compact 4.0 is a file based database and has native visual studio 2010 support. It’s a simple way of data store and off Couse pretty handy in few development scenario.

Adding the database is pretty simple. Right click on the project folder and select add new item, from the add new item wizard select Data category, and you would find the item template named “SQL Server Compact 4.0 Local Database”, which is your target template. Now select the item and give a suitable name. Now click add.

image

If you are trying to add the database file in a asp.net project you would be presented with a message box dialog like bellow. And you should select “Yes”. By Asp.net convention any data related stuff should go to App_Data Folder which is a special folder for asp.net project.

image

Now after that you should find a file with the same name of your given database name in app_data folder and as well as a data connection would be added to the server explorer. That’s it you are good to go.

image

Now then if we try to use the same database with WPF Project you would see the warning like Bellow screen shot. It simply says that you can not use this version of database with dataset designer. I mean if you thinking if using Type Dataset and data adapter to fill your data, you shouldn’t probably use this. Visual studio 2010 dataset designer does not have native support for this.

 

image

In this case you should use local Database template rather that version 4.0. And after selecting the local database template click add, a data source configuration wizard will be lunched the finish the steps of the wizard you will get the data file added in you project.

image

In this post we have see how we can add the SQL Server Compact4.0 Local Database in visual studio 2010. In my next post we would see how we can design a effective database quickly using visual studio or perhaps SQL Server management studio.

Wednesday, August 3, 2011

Using LINQ to SQL with SQLite database

In my previous short article we have discussed about how to use Ado.net Entity Framework with SQLite database. And we have witnessed that its almost as like as SQL server in context of ease and usability when you have the right provider.

Today we are going to see how we can use LINQ to SQL with SQLite database. We always looks for ways that would make our life easy and most important no more re-inventing the wheel. By default you can not drag and drop tables from server explorer or from data connections. Its because we don’t have any built in provider that support LINQ and if you try to do so you would certainly encounter with the following error.

AddRelation

Now, I know what am I going to show you wont please you but it certainly serve our purpose to use LINQ with SQLite. There is no magic or rocket engineering behind this, we have a DBLinq open source distribution that come with various sort of database support. For this particular case lets stick to SQLite. The binaries can be found here,  http://code.google.com/p/dblinq2007/, please download latest binaries from this site.

Now its time to generate the OurDatabase.dbml file. the steps are not that much complex, Located the DBLinq package that you downloaded from Google code, then unzip in a suitable folder location where you can access it easily.

Note that you need to copy the System.Data.SQLite dll in the DBLinq directory. 

image

Step 1: Create the dbml file

DbMetal /provider:Sqlite /conn "Data Source=File.db3" /dbml:File.dbml

Step 2: Create the code file for the dbml file

DbMetal /code:File.cs File.dbml

Copy those files to the files. That’s it you are good to go.


Generated DBML


Make sure that every thing compiles okay by hitting build. Bellow I have put done a simple code snippet to demonstrate how to use this dbml to retrieve data.

 protected void Page_Load(object sender, EventArgs e)
{
string ConStr = "Data Source=" + HttpContext.Current.Server.MapPath("App_Data\\File.s3db") + ";Version=3;";
var connection = new SQLiteConnection(
ConStr
);
connection.Open();
var db = new Main(connection,new SqliteVendor());
var users = db.User;
var item = users.Take(10).ToList();
}



I hope this above code is self explanatory. Best of luck and happy coding.

Wednesday, July 27, 2011

Using SQLite with Entity Framework in Visual Studio 2010

Introduction

In my previews blog post we have seen how using a simple “data provider” provided by http://sqlite.phxsoftware.com/ can make our life easier in context of SQLite in .net. In this short article we are going to see how we can use SQLite to generate Entity Framework Data model.

Choosing the Provider

First thing first create any type of project in Visual studio 2010. But I would prefer an web application or windows forms or perhaps a WPF application. Now click on project and select add new item to add a new item type. From Add new item wizard select “Ado.net Entity Data Model” and click on add this will brought up the Entity data model wizard.

  • Step 1: Select Generate from Database
  • Step 2: In next window select New connection
  • Step 3: Connection properties window will popup and the select right kind of provider for SQLite.
  • Step 4: After that the Connection properties will have browser or New db,

Create Data Model

  • Step 5: Now select existing db if you have using browser or New to create new db.
  • Step 6: Continue with the wizard to select database table items to include in model.
  • Step 7: Click finish to close the wizard and a data model will be generated for you.

Data Model Created

If you had any relationship in the database those will be automatically be synchronized in data model, that’s it we are good to jump in the code to retrieve data and do all type of necessary stuff that we must do in a database. Best of luck and happy coding.

Edit SQLite database using Visual Studio 2010 or SQLite Administrator

Introduction

In my previous blog I have shared few useful information about SQLite Embedded database and how to use its provider to create an connection using System.Data.SQLite. We have also seen a simple tool named “SQLite Administrator” which is very handy to use with SQLite database. In this short article we will see that how we can create and manipulate  data using Visual Studio 2010 or SQLite Administrator.

Creating Table in Visual Studio 2010

Select the SQLite connection that you created and expend the Tables node, then right click and select “Add New Table” that’s it you are good to go to add a table just like the bellow figure. I am sure you guys have done this hundreds of time in SQL server, this time its just SQLite. you might see a warning when you first enter into edit of table editor.

Creating Table In VS2010

Using SQLite Administrator

Double click on the SQLite database file and right click on tables and click "Create Table”, rest of the UI is fanatic to Create the table. Set field as primary key or assign auto increment to primary key all can be done via simple clicks. So no custom hand written SQL any more.

Edit Table in SQLite Administrator

Creating Relations in Visual Studio 2010

Creating table relations are easy in visual studio, just click on relation icon, the icon beside primary key, in fact to be precise right side icon of primary key button. Or perhaps you can select a table and then click on relations, this will popup an widget to create relation.

AddRelation

Creating auto increment primary key is a not that much difficult also, now a days in every table we use auto increment key so we must discuss about it. at first glance we didn’t find any button or option to assign it directly. You can use SQLite Administrator to add it in few clicks, but to add in Visual Studio 2010 you got to bring the indexes window, just click on Indexes after that you will find option to add auto increment column.

Edit Auto Increment in Vs2010

I hope this information's will be helpful to us to work better with SQLite. Hope to write more information's about SQLite in near future. Happy coding.

Tuesday, July 26, 2011

SQLite management tool.

SQLite have lots of management tools, some of them are open source and some of them are trial ware and some of them are commercial. I found “SQLite Administrator” Pretty easy to use and handy tool as far as SQLite database file is concern.

A complete list of SQLite management tools can be found here “http://sqlite.com/cvstrac/wiki?p=ManagementTools” download the use what ever best suits you.

Today I am going to talk about only in SQLite Administrator, It can be downloaded from the following site.

http://sqliteadmin.orbmu2k.de/

A Complete list of feature is given In that site.

image

Features:

  • Create / Modify / Delete Tables by Wizard
  • Create / Modify / Delete Indices by Wizard
  • Create / Modify / Delete Views by Wizard
  • Create / Modify / Delete Triggers by Wizard
  • SQL Code Completion that supports table aliases
  • SQL Code Highlighting
  • SQL Error Locating
  • Import Data from CSV Files
  • Export Data ( XLS / CSV / HTML / XML )
  • Store User Queries into Database
  • Search for User Queries
  • Store Images into Blob Fields ( JPG / BMP )
  • Show SQL of each Database Item
  • Migrate SQLite2 Databases to SQLite3
  • Try to keep Indices and Triggers after modifying a Table

 

Note

This tool need no installations what so ever. The whole package is in a zip file and need zero installation, just unzip and open the exe that’s it, and All of the functionality is pretty easy and it has very intuitive UI. I would recommend it to every one who work with SQLite.

Using SQLite in Visual Studio 2010

Introduction

Every now and then we need a simple database solution which is light, small and pretty easy to use. What more can be useful other than SQLite, A simple yet very powerful tool to support database for any kind of application needs. When we started this research work we had a particular focus to choose right kind of database depending on few criteria.

  • We don’t want to use a service based database rather a file system based database.
  • Client have to be light, fast and support blob data.
  • We don’t want to install any client or framework in client machine

 

Background

After few minutes of research in the internet we came up with few embedded file system database that can be used in .net and has support, necessary tool and provider.

  1. SQLite
  2. SQL Compact Database
  3. Firebird

Among those SQL Compact DB is really have good support with visual studio IDE and very easy to use but it has its own limitations and we would definitely discuss in future about it. But the end result was that we found that SQLite is winner in every case and that’s why we choose to recommend it in this short article.

Adding the provider

Change Data Source

Next step is to add a data connection in server explorer in Visual studio 2010. When you click on add connection by default you don’t have provider added in visual studio, so we have to add it using a third-party tool. You can download the provider for SQLite from http://sqlite.phxsoftware.com/ site. “SQLite-1.0.66.0-setup” this is the version we used for this particular case. When you install this provider you would be given an option to integrate this in vs2008 and vs2010.

Installing the provider

After installing the provider when you get back to the add data connection in server explorer you would see an new provider is available for SQLite.

Adding the connection is Server Explorer

SQLite Provider

Go ahead and click on after choosing SQLite Database File. Next we will be presented with a screen where you would either choose an existing database or created a new database file.

Create New SQLLite DB

That’s it your connection string and database connection is set up and you are good to go with design of the database. Few interesting note on this particular case. My SQL database have no database diagram support yet. But we hope that this will be provided soon. After adding connection we can created tables and add necessary relations to the table.

Conclusion

In this short article we have seen that how easily SQLite can be used in visual studio 2010 using a provider to create connection in server explorer. Next we would discuss how to use SQL Lite to create a data layer using Entity Framework.

Update

New article with new provider by SQLite org is published here http://munnaondotnet.blogspot.com/2012/06/using-sqlite-in-visual-studio-2010-with.html