tags:

views:

1797

answers:

6

How do i create a db file in C#? a friend told me it was in the toolbox and not to use sqlite. I dont see anything that could be it, nor what it is called. google didnt help:(

+3  A: 

There is no file-based database provider built in to c# or the .NET Framework. There are of course pre-existing connectors for using SQL Server (which includes SQL Express), but if you need a fully functional RDBMS that is file-based, you need to use something like SQLite or Firebird (also a fan of VistaDB, not free or open source but VERY solid and pretty affordable).

Rex M
What about XML - not file-based?
cdonner
@cdonner XML is not a database by most common definitions. (Though of course formally it can be.)
Rex M
A: 

You are mistaken. Databases are not developed in C#. Databases are built using a database system such as Oracle, MS SQL Server, MySQL, and numerous others.

Once you build a database using one of the above providers, you can then perform actions on the database using your programming language of choice (in your case C#) to get data out of and put data into it.

TheTXI
That's not entirely true, necessarily. Products like VistaDB are fully functional RDBMS written in c#.
Rex M
@Rex: In the context of the question it is a fairly accurate statement. He is looking at how to create a database in C#, not an RDBMS.
TheTXI
A: 

If you are using Visual Studio or Web Developer Express, there are indeed ways to easily create a MS SQLExpress database. Just go to Add New Item... and it should be one of the available file types.

Keep in mind you have to have installed either Microsoft SQL Express Edition (free, as in beer!) or Microsoft SQL (very un-free!, in all senses). If you haven't done this, you don't get the option of creating a database file so easily. If you have got it yet, you can get it here.

As other answerers have mentioned, strictly speaking this is NOT a C# feature. MS SQL and it's derivatives, are database applications, much like Oracle, MySQL, or PostgreSQL. It's just that Microsoft Visual Studio makes using the Microsoft database product very easy by default. Differentiating between C#, Visual Studio, and any database programs will probably get you better answers, faster, no matter where you ask. :)

Dustman
+5  A: 

Could it be...

SQL Server Compact Edition – A lightweight, in-process database engine designed to run on devices and desktops and is geared toward local data storage. Compact Edition includes a subset of SQL Server 2005 data types and shares common elements of the Transact-SQL (T-SQL) language with the data service engines.

spender
+1  A: 

On the Add New Item menu: "Service-based Database" or "Sql Server Database" if it is an asp.net application. I am sure your friend meant it as "create a sql express db file in Visual Studio".

That said, if you wanted to fill an empty database, with tables that correspond to a c# model, you could create a linq2sql model, and use its CreateDatabase to do that for you :)

You might want to check this http://quickstarts.asp.net/QuickStartv20/aspnet/doc/data/vwd.aspx (visual web developer link, but it applies).

For a full/in-depth explanation of how SQL express can be used with a semi file based approach check and its limitations: http://www.databasejournal.com/features/mssql/article.php/3704171/SQL-Server-2005-Express-Edition---Part-8---XCopy-Deployment.htm

eglasius
A: 

Hello guys, I know this forum is a bit old but it is relevant to this dilemma i am facing. there is an application i am writing i C#, on this application I am getting data from an SQL database and saving it on a dataset, then to a text file. BUT now, what i want now is to save the data into a paradox DB file, which i have done before with Delphi but struggling in C#.

Can you please help!!!!

If you have a question then please post it as a question, not as an answer to an existing question. This is not a forum — it is a question and answer site. There is an 'Ask Question' button at the top-right of the site.
Paul Ruane