datacontext create connnectionstring

60 Views Asked by At

I'm trying to write a Windows Form app. I need to use a database and since I know how to create a db in WP8 (using Datacontext) I tried to use the same class with this form project. I have a problem: how can I define the connectionstring in the StudentDatacontext class in order to create a local database in the folder of my application?

(I aleready tried using

public static string ConnectionString = @"c:\students.mdf";

but my application explodes on db.CreateDatabase();

    using (StudenteDataContext db = new StudenteDataContext(StudenteDataContext.ConnectionString))
            {
                if (!db.DatabaseExists())
                {
                    db.CreateDatabase();
                }

)

Thank you for the help!

0

There are 0 best solutions below