7

How to create a simple Local SQL database & insert values into it using C#? can any one provide me a sample code or project link.. i googled a bit, i am not getting how to do.. if you can advice it would be great

5
  • 3
    By local do you mean server-less database? Like embedded or in a file? Something like SQL Server Compact? microsoft.com/sqlserver/2008/en/us/compact.aspx Commented Feb 10, 2011 at 10:39
  • 1
    By local means, like simple sql file creation in hardisk and accessing data like that.. Commented Feb 10, 2011 at 10:43
  • Then that's exactly what I suggested. You can work with the database directly in Visual Studio (create DB, tables, modify, ...) ;) Commented Feb 10, 2011 at 11:19
  • i want to do it programmatically using C# functions.. is there a way? Commented Feb 10, 2011 at 11:28
  • It is. Check out msdn msdn.microsoft.com/en-us/library/ec4st0e3.aspx a sample to create the DB is here msdn.microsoft.com/en-us/library/… Commented Feb 10, 2011 at 11:32

3 Answers 3

3

If you are creating a Desktop application, you can create a local Sql server Ce (Compact edition) database.

When you install Visual C# 2008 Express, It will automatically install SQL Compact 3.5 on your box.

Here is an excellent Getting started tutorial on the topic:

http://dotnetperls.com/sqlce

Sign up to request clarification or add additional context in comments.

Comments

2

I would use SQLite. It's simple and it doesn't need any kind of installation, the full database it's only a file.

Comments

0

Sql Server Compact is a great embedded database. It is also fully documented on MSDN, see System.Data.SqlServerCe Namespace.

You can easily create and modify databases programatically, see SqlCeEngine.CreateDatabase Method.

You can download it on the SQL Server Compact Download Page.

3 Comments

Hey, CE for windows mobile right. SO can we use the same for desktop?
@LLL: CE as in SQL Server Compact Edition, not Windows CE.
oh.. Jaroslav Jandek Thanks..i will have look at it once.. Thanks again

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.