2

I want to have some tips. I have worked on SQL databases in c# but i am developing a new small level application that only has to store some contact numbers so i planed for access because SQL will be overkill so i have never been to access database. How to Add access database file --> there is no file to add when I add new item to solution Consumption is same with a bit changes as that of SQL? like

"SELECT * FROM USERS WHERE uName=@username"
Fionnuala
  • 90,370
  • 7
  • 114
  • 152
Afnan Bashir
  • 7,319
  • 20
  • 76
  • 138

4 Answers4

2

Why Don't you try using SQL lite or SQL CE? These use a file-base approach to store your data (ie they put a file in your app_data folder, as I think you want with access).

Some pointers

http://weblogs.asp.net/scottgu/archive/2010/06/30/new-embedded-database-support-with-asp-net.aspx

http://dotnetperls.com/sqlce

http://www.sqlite.org/

Jaime
  • 6,736
  • 1
  • 26
  • 42
  • 1
    @Jaime: what is the advantage of your proposal over using an Access db ? Thanks – iDevlop Dec 04 '10 at 14:11
  • Accessis an old solution and does not support many features (and some SQL constructs). You don't need access installed on your computer (granted you need SQL CE installed, but is free:). Supports the same API as full SQL som ORMs work the same. – Jaime Dec 04 '10 at 14:17
  • 1
    @Jamie - Access really isn't an "old solution", more of a different solution that's been around for awhile. SQL Server has been around for awhile as well, does that make it an "old solution" as well? You don't need Access installed on your computer; you can manipulate everything through the oledb provider. One of the disadvantage of using Access is the lack of an Entity Framework provider (though, I think I saw someone create a custom wrapper for Access to Entities). Anyhow, for small projects, Access is a viable solution and does support nearly all SQL constructs. – Metro Smurf Dec 04 '10 at 14:38
  • You're right I may be implying that is bad because is old... That is not the case... What I ment is that it will tend to have less support than the other solutions (IE EF support, L2S, etc). Of course is a viable option, but so is SQL CE and you get some added bonuses. – Jaime Dec 04 '10 at 14:43
  • Ok but I have to give this application as a setup file which i will be creating from setup studio.Question arises that at other computer that dose not have any thing except OS what would SQL CE and SQL Lite require?I mean what about database Engine and My application is Desktop Application dose it makes any difference using SQL Lite or CE as one of your link says about usage in ASP.Net – Afnan Bashir Dec 04 '10 at 17:32
  • With SQL CE (not that this is from MS) you would not need anything installed in the client computer, you would just send the file along with the app, or create it on first run of the app. Same with SQL lite (this is open source) – Jaime Dec 04 '10 at 18:03
2

While I completely agree with Jaime on SQL Lite and SQL Compact Edition and back him up thoroughly, to answer your question, there will not be an Access Database to be added to the project from Visual Studio. However you can simply create an Access Database from Microsoft Access and manipulate it from C#. If you have previous experience in SQL Server, this would be very easy. Most of the objects and methods that you used from System.Data.SqlClient would be replaced by System.Data.OleDb. And yes you can use SQL syntax to interact with the database. As for the connection string to use, refer to Connection Strings for Access 2007

Ranhiru Jude Cooray
  • 19,542
  • 20
  • 83
  • 128
0

Use SQL Lite:

Is there a .NET/C# wrapper for SQLite?

Community
  • 1
  • 1
Robin Orheden
  • 2,714
  • 23
  • 24
0

You do not need to install anything to use Jet, the database used by Access. Jet has been installed with all versions of Windows for some time now. If you are using C# to work with the database, it will be very easy to install on other PCs, in that you can be fairly sure that nearly everyone will have Jet.

Fionnuala
  • 90,370
  • 7
  • 114
  • 152