Creating an SQL Database for Windows Forms Application - c#

I'm still a little new to programming in C# and I'm a little puzzled about how to create a SQL database which will be accessible by many different computers over a mapped path connection. Can anyone suggest the best way to do this?
Many thanks.

I would caution you against using a shared file database over a mapped UNC path. There is a very good reason that database servers exist. I would recommend you try SQL Express 2012 if you are looking to save money and have only a small amount of data and a few users.

If you want to create a database using C# code here is a link http://www.codeproject.com/Articles/10213/Create-an-SQL-Server-Database-Using-Csharp. Otherwise you can just use the SQL Server management studio to create a new database - here's the link http://msdn.microsoft.com/en-us/library/ms186312%28v=sql.90%29.aspx.

Related

c# local database / dataset

I'm new on C# and I want to have my data on a local database. The problem is I can't understand how to do it. I created a sgt.sdf (database) file and a sgtDataSet.xsd (dataset) but I don't seem to understand the relation between those two files. Can anyone explain me how to work properly with this?
If you are new to C# and learning it, so you should be able to start learning about databases, example databases on a SQL Server or likewise.
Or you could use a localDB if you don't want to setup a SQL Server.
If you wanna start with something less cnfusing, i sugest using an access database. Sdf databases are u reliable. They can be broken without even knowing.
When using access you will be using the OleDB code in C# it's almost the same as the other ones.
Hope it helped :)

create setup file and let user choose where to save database

with very short words,
i have created a project which contains database using sql server; and of course i want the database to be separated or in some place away from drive C so i want to let the user choose where to save his database when he install program to be able to move it if necessary and not to lose data all the time because employees are not well-trained using computers
or if possible make whole program portable
can somebody help me or send me link with clear explanation because i couldn't find something helpful
thnx in advance
It's very easy to create a database dynamically using SQL Server Compact Edition (SQL CE) which is a compact relational database that is very easy to configure and deploy from your application dynamically. It sounds like a viable solution for the environment you describe. Rather than recycling code I found some good beginner resources for you:
Getting Started with SQL Server Compact Edition
Create a SQL Server Compact Edition Database
Create a Table in SQL Server Compact Edition

What database can I use that does not need an application to be installed

Hi I am creating a windows application and I need to select a database. I dont want to go out and install sql server express for every person who uses my application.
What database can I use that does not need an application to be installed. I would like to have a database for each customer that is stored locally.
I use SQLite (http://www.sqlite.org/). It's free and you just have to distribute a dll
It allows you to manage up to 14 terabytes sized DBs (http://www.sqlite.org/limits.html)
It would depend on what you wanted to use it for, if you just want one database for each user then I would look at using SQLite
If you need one database for every user that SQL server installed on a remote server would be ideal
SQLite rocks in these scenarios.
Use either SQLite or SQL Server Compact Edition
I'd think of using SQLite. It is serverless and requires no preconfiguration on the users part. Each database is simply kept as a single file. Read this SQLite
I think its better to use : SQL Light database might resolve your problem.
Limits In SQLite

C# database in a file

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:(
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.
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).
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
Perhaps you might try Microsoft LocalDB.
It is file based but uses a low level SQLExpress Installation to host it.
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. :)
Every database has a file system in some binary format more than likely custom and uses a cache to control the flow of the database(s) lifetime.
If you create a database system, you will need some type of cache because you only want to read from the file if the cache has already released it.
If you have 1000 clients tapping into the same db, you certainly don't want to read/write to the file for each client request, so you want to manage a queue of clients and run it against the cache so that the cache knows not to release the db after its time span for lifetime is reached put to rather update the time span, therefore, not having to reload the file, if disposed and queued again, until the queue referencing the db object is empty.
Creating a well designed cache it used by all rdbms's so that duplicate objects are not created and files are not reloaded if not need be.
You can use
FileDB - A C# database to store files
http://filedb.codeplex.com
There is a MVC Example in the source that allows you to upload files and also has drag and drop support.
It then saves it into just one file in a location that you specified.
Like this:
private string pathDB = #"C:\CMS-MVC\Parts\FileManager\filedb-19055\trunk\MvcTest\Data\MvcData.dat";
That one file will store all of your files in that one "container".
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.

Database Choice for a C# 2008 front end

I was wondering what and why you would choose to be able to make a database that can support no more than 100 users with no more than 10 using it at once with a Visual Studio 2008 C# Windows Form front end to access it by. I have to access the database over a network connection, not just on the local machine. I also need to define where the database is found at run-time in the code as opposed to the "Data Source" view in Visual Studio. If my question needs reframing or is not understood, let me know and I will adjust. Part of my problem is I am not sure even how to ask the right question, much less what the answer is.
If it is not for comercial purposes you can try SQL Server 2008 Express. It can integrate nicely with Visual Studio 2008 for development and has support for LINQ, Entity Data Model and ADO.NET Entity Framework to make it easy to create next generation data-enabled applications.
http://www.microsoft.com/express/sql/default.aspx
You can also store your connections strings in the application configuration file and retrieve them programatically for setting up the database connection.
http://www.codeguru.com/columns/DotNet/article.php/c7987/
I would probably go with Sql Server Express, it's free and works well with .NET. Assuming your schema is not changing at runtime you can probably still use the design time data source features in Visual Studio. The connection information is stored in the app.config file which you can update after the app is deployed to point to a different database. You can also develop a class that gets the connection info from somewhere else as well and just use that when you need to open a database connection.
I know using mssql you can pick between different connection strings for all of your db calls, just do something like
Command.Connection = GetMyConnectionWithWhateverLogicINeed();
I'd have a look at Sql Server Workgroup Edition
http://www.microsoft.com/sql/editions/workgroup/
Express edition used to have some limiting features for more than about 5 users and it is not supplied with any management tools which is a bit disheartening.
I'm not sure I totally get what you are asking, Matt, but I can tell you that I developed a series of apps written with VS 2008 and we used a MySQL DB for it. While I'm definitely not a DB guru at this point, I've not had many issues with using MySQL.
Perhaps if you rephrase your question, we can provide better answers.
SQLite for sure.
ADO 2.0 Provider

Categories

Resources