Jump to content
  • Advertisement
Sign in to follow this  
BrknPhoenix

[C#] How to create a local database file with no connection to a server

This topic is 3975 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was wondering if anyone had any information on using C# to create a database that is stored on the users PC that would be accessed without any sort of connection to a server. I've been looking for tutorials online, but all the tutorials I find are for connecting to another computer running SQL Server. That is not what I want. I just wanted to use a database to store game data. Anyone got any links?

Share this post


Link to post
Share on other sites
Advertisement
From the MySQL 5.0 Reference Manual :

"We also provide MySQL Server as an embedded multi-threaded library that you can link into your application to get a smaller, faster, easier-to-manage standalone product. "

I know for C#, there is a plugin (for visual studio) called connector.net. Im just learning this stuff, but with connector, connecting/editing/etc.. a database is as easy as :

1) Add reference MySQL.Data

2) using MySql.Data.MySqlClient;

3) Create connection object :
MySql.Data.MySqlClient.MySqlConnection conn = new MySqlConnection();

4)Create connection string
conn.ConnectionString = "server=127.0.0.1;Uid=root;Pwd=jason;Database=test;";

5) call conn.Open()

And theres handy GUIs too.

Share this post


Link to post
Share on other sites
Crap.

Only in C++ at the moment.

The ability to embedded SQL server using C# is planned for 5.2.

But tons of other people want to do it too.
http://forums.mysql.com/read.php?58,5043,159981#msg-159981


Share this post


Link to post
Share on other sites
Embedding the MySQL engine will likely require you to licence your code under the GPL, FWIW. If that's not your intention, read the licence.

Also, I don't see how XML is the way to go: XML isn't a storage solution, it's only a markup language. It's perfectly possible to have a SQL DB that stores its data in a bunch of XML flat files (although that would be moronic in 99% of the cases), but the interface would still be SQL. XML won't allow you to run queries, to update, select, delete, ... your data, to alter, create, delete tables, to have checks, triggers, stored procedures, etc. All of that you'll have to code by yourself.

I'd suggest looking at SQLite or, if you need something heavier and don't need portability to non-Windows systems(*), Firebird, which has an embedded server. This article apparently explains how to get it to work with .NET.


(*) The standalone server apparently is a Windows-only feature, but the fullblown server is available for non-Windows systems as well.

Share this post


Link to post
Share on other sites
let_bound

Firebird sounds like exactly what the OP (and myslef) have been looking for.

How ironic. OP username is BrknPhoenix, and the solution to his problem was a thing called 'firebird'. Lol, nerd humor I guess.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!