Thread Safe Way To Access Sql Ce Database
Background: In my windows phone project. I use local SQL CE database to store date. The create the database tables using LINQ to SQL programmatically. This database is accessed thr
Solution 1:
Andy as mentioned above (to be honest they beat me) the problem was accessing the database when another process still had the connection opened. Basically it can be easily fixed by placing any code you run against the database inside of a using block like so:
using (MyDataContext db = new MyDataContext("isostore:/MyData.sdf"))
{
//Run database logic here
}
I guess in a sense it makes perfect sense for the error. Same thing happens with open files in WP7.
For more information and an example check out this page.
Post a Comment for "Thread Safe Way To Access Sql Ce Database"