Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top