Is it possible to use two databases in one application, i.e. SQL Server database and Local Database (.sdf = SQL Server Compact Edition)?
So some user can use it on network, but for another users is that not important.
Can I create two project, one for SQL Server for example (I have already LINQ to SQL). And another for Local Database where .sdf file is added with DataSet and so on. And than I planned to compile my solution including one of this two project, depends on my customer's needs (SQL Server or Local Database). I have also Business Layer and GUI which stay the same. Can this be done or there is some other way how to do this?
I am using Visual Studio 2012
Thanks for any tips.
Compact is not fully compatible with "real" SQL Server. Check the LocalDB instead: supports everything that express edition does, but simplified setup and doesn't run as a windows service.
Related
here is the problem I am facing now. I have created an application that uses local database (this was created by Add -> New Item -> Local Database. Afterwards I have added tables under this .sdf database.
Then I have connected to this database using Add -> New Item -> ADO.NET Entity Data Model.
Everything works like a charm, unless I was asked to move this database to a place, where multiple people could access this database and work with it.
Therefore, as I have no previous experience with databases, I have treated this .sdf file as any other file (let's say Excel workbook) and I thought that I could simply take already existing database, copy it on server computer (e.g. \Server001\Database\Database1.sdf) and simply change connection string under app.config.
However the problem is that this does not work. As I didn't know how to change connection string, I created new application, where I have tried to connect to this database located on a server computer; however I received the following error:
SQL Server Compact does not support opening database files on a network share.
I already have fully functioning program, but I have no idea how to make it work with multiple users. I have tied to google for solution, but all I could find is how to create local database, not how to make it accessible by placing it in server computer.
Could you guys please help me? If you need more details, please let me know!
P.S. This is WPF application, .NET 4.5, created using Visual Studio 2012 Professional.
Thank you!
The error message pretty much sums up the problem: SQL Server Compact does not support opening database files on a network share.
SQL Server Compact (aka "local database") is to be consumed by a local application; even if it was a web app serving many requests, the application itself is local.
If you want to have multiple remote connections (i.e. centralized DB, distributed app), you should look at using an instance of SQL Server (any SKU would probably work, even SQL Server Express). Those will use MDF files instead of SDF files, so you might want to refer to Convert .sdf database to .mdf database. You'll probably also need to set up a user identity for your connection string, so check out this link on CREATE USER and Difference between a User and a Login in SQL Server to understand how that can be configured.
I have created a new MVC3 project and used the ADO.NET Entity Data Model to map out my existing database. It worked great.
Now, that is a database I don't want to affect when doing development of my web app, so I was looking to now attach that data model to a local database (haven't selected one yet, suggestions welcome. I was thinking SQL Server CE or MySQL).
Does anyone have any ideas on how to do this? I'd be nice to keep the existing connection string to my live database as well as this development database environment.
You can generate another matching DB using whatever technology you want (though it would be good to keep them similar to your production DB) and then have a Web.Debug and a Web.Release setup.
If you look at swapping out the configuration, connection string portion of your web.config file you can easily swap from development to production.
http://msdn.microsoft.com/en-us/library/dd465326.aspx
This provides the relevant information for the transform statements in your Web.config file, but from the sounds of it you can simply swap the connection portion of your web.config and get what you want.
Is the existing database on your machine, or on a server somewhere?
If it's on your machine, just back it up and restore it to a different database; i.e. if your database is called XYZ, back it up and restore it to a database called XYZ-Testing. You can then connect to and use XYZ-testing without affecting XYZ.
If the existing database is on a server somewhere, the easiest solution is to install SQL Express on your machine, and then backup the database on the server and restore it on your machine.
Doing this will make your life much easier than trying to use a different database type (SQL CE or MySQL).
Another option would be to use SQL Server Data Tools (SSDT) free download, add-in to VS or stand-alone if no VS, and then to create a local database project for development. I wrote a blog post about using SSDT as well.
I'm developing a WPF application, which connects MS SQL2008 database remotely.
The app communicates with the database by Linq-to-SQL. pretty handy.
However, because of the slow database server, I'm trying to use local database caching.
"VS2010 > Add Item > Local database cache" wizard could be a solution, but it uses DataSet and SQL Compact(*.sdf).
I found Linq-To-SQL cannot generate classes from the SQL COMPACT edition!
(when I drag tables, error pops up and says 'unsupported data provider')
So, is there any solution to use Linq-to-SQL with local database cache?
or is there any database sync method played with Linq-to-SQL?
If you still want to go the sql compact way, Lightspeed is a linq-to-sql provider that supports a variety of data-sources. it includes mssql compact.
http://www.mindscapehq.com/products/lightspeed
The free version is sufficient for most projects, with an 8 model/class limit.
Ive used it as a linq provider for MySql and Sql Compact before and it's been great.
You can see everything it supports and how it compares to other existing systems like it here:
http://www.mindscapehq.com/products/lightspeed/comparing-lightspeed
the Local Database Cache Wizard only supports SQL Ce on the client side. if you have SQL Express/SQL Server on the client side, you can use Sync Framework still.
see following samples/tutorials using Sync Framework:
Synchronizing SQL Server and SQL Express
Database Sync:SQL Server and SQL Express 2-Tier
nevermind if it mentions SQLExpress, the SQLSyncProvider referenced in the code should work against SQL Express,SQL Server, and SQL Azure
This might sound a silly question but I've really spend hours in trying to find a solution...
I have a local database on SQL Server and it is used with a C# application.. The only way I view the database is through SQL Server.. It is accessible and altered in my application when I am running the application on my developing PC, but when I run it on another PC the database is not found (obviously) .. How can I include the database sources when I am compiling the program, (so that it would be also found when I run it on other PCs) ?
Initially I used SQL Server CE and I achieved portability, but I had to include stored procedures, and this edition doesn't accept them :/ so I had to turn my attention to the latter type.
Sorry for my terrible English ! :(
Thanks in advance
How can I include the database sources when I am compiling the program, (so that it would be also found when I run it on other PCs) ?
You can't. SQL Server license prohibits distributing parts of it like that, plus there is no documented way to do that. If you need SQL Server on the box, it needs to come from the installer. You can create an installer for your own product, and your installer can install SQL Server if it's needed as a prerequisite.
Alternatively, you could look at other database options such as SQLite for a file-based database. You can distribute the components of SQLite.
If you need a local sql server on each pc where your application runs then you should look into the Express edition of MS SQL Server. It is the free with limitations version of MS SQL Server.
I am developing an application in C#/WPF that requires a distributed data model, as it will have both online and offline access.
My current thoughts are to develop the first version of the application against SQL Server express and LINQ to SQL. Then use the schema to create a SQL Express Compact DB (and modify the connection string) for distribution.
Once that version is how I like it, I will add the "distributededness" to the application by creating a web service that the application syncs its local database with.
My questions are: is this a good approach? And will I run into problems by turning my reference to a "real" SQL server into a reference to a local self-contained SQL database file? I had issues trying to create LINQ to SQL with a compact DB reference, but I can't see how it is different then a reference to a "real" server.
Thanks
At the moment I am considering this:
http://www.mindscape.co.nz/products/lightspeed/
Then use LINQ to SQLITE for my application.
Are there any comments on this approach?