I’m writing a program & I want to have 2 SQL Server databases. One on the client and one on the server. I would like to check the internet connectivity in my program and if the user is connected to the internet the server database is used and if it’s offline then the client database is used and then when the user connects to the internet the server database updates itself with the client database.
As the two databases are exactly the same and have the same tables how can I do this? I mean connection strings and the dbml file contents.
Since you’ve mentioned dbml, I’ve assumed LINQ2SQL.
I would suggest you add 2 connection strings, one for client, one for server.
Then use the
DataContext()constructor which takes the connection string name to determine which database the context points to. e.g. hereEdit
I would suggest a helper method / factory something like this:
And in your code using DataContexts: