I can't seem to find any straight-forward guides on how to create a windows forms application with C# .NET in Visual Studio 2010 that uses a local database. When I create the local database, a .sdf file, I can't figure out how to have my form access it. All the discussions I have been able to find on it seem to assume I know more than I do on the subject. Can anyone direct me towards a straight-forward beginner's guide on the subject, or outline the steps I need to take?
Asked
Active
Viewed 2.3k times
4
-
1Thats not an easy question to answer. You are welcome to join me in the C# chat room. I may be able to help you – FrostyFire Jan 20 '13 at 23:22
-
I say look into Linq-To-Sql. There are tons of tutorials on it and it makes it a whole lot easier to work with databases locally and on the server – DJ Burb Jan 21 '13 at 00:05
-
@DJBurb I plan on learning more about Linq-To-Sql very soon. – Alex Jan 21 '13 at 01:17
2 Answers
3
Check here, it will walk you through what you need to do...if you have any specific issues with specific parts of the linked process, let us know.

Stephen Byrne
- 7,400
- 1
- 31
- 51
-
This tutorial is very helpful. This mostly looks like the stuff I have been seeing already, but having the step-by-step guide should make it easier for me to find where my problem is. Thanks. – Alex Jan 21 '13 at 01:18
-
I'm a bit late with this feedback, but the link worked out perfectly for me. Another user on here convinced me to try out SQLite, though, and it is actually fitting my exact purpose a bit better. Thanks again for the help. – Alex Feb 16 '13 at 00:14
0
I found this library very helpful
https://github.com/martincostello/sqllocaldb
Once added via nuget its very easy to use
ISqlLocalDbProvider provider = new SqlLocalDbProvider();
ISqlLocalDbInstance instance = provider.GetOrCreateInstance("MyInstance");
instance.Start();
using (SqlConnection connection = instance.CreateConnection())
{
connection.Open();
// Use the connection...
}
instance.Stop();

Lord Darth Vader
- 1,895
- 1
- 17
- 26