SQL Server Express Database hosted on Network Share - Is it Possible? - c#

I've started work on a project that requires an SQL Server Database. I will be building a front end application in c# .Net 3.5, that will use LINQ to SQL.
I need to host the database on a network share so that a group of users can all gain access to the database, mainly for read only.
I know that SQL Server Compact is designed to run on the local machine and my company is not willing to front the costs of a full blooded SQL Server.
Is there a way of achieving what I need to do via SQL Server Express?
If so, which are the best guides on how to set this up?
Thanks

If you go with the (free) SQL Server express, it will do what you need - but you don't access it thru a network shared drive - the server would be located by an ip address (or equivalent DNS).
You c# application would be talking to a service - SQL Server - not reading to/from a database file. The service will handle the interaction with the database. Only the SQL Server service will need to know where the file actually is - your client machines won't know and shouldn't care.
If your background is only with file-based databases - i.e. MS Access, you need to change your mindset a bit about how SQL server works.

You can install a SQL Server Express instance and install the SQL Management Studio Express for all users who need access to the database. The Express Edition is a standard SQL server with limitations regarding the number of processors used, the maximum amount of memory used and the maximum database size. If these limitations don't bother you, it should work fine for you.
Using a network share as a database storage to access db files from several clients is a bad idea, as the sql server instance should always be the only one directly accessing the database, both for read and write access. Configuring several instances of SQL Server to access the same database will probably not work - and if it works, it will probably create havoc in your database files.

Related

Do I have to install sql server on each client to use my disk top application?

I have a disk top application made by c# visual studio. My question is do I have to setup SQL server on each client to use my application? or there is another way to attach my database with my application and compress it as one and send to each client and those just extract that file and use the application correctly?
On a real scenario, your database should be placed on a remote server and the clients should only access the database through your API (that will need to support authentication or any other identity based systems).
If your application only needs to store some local information (relevant only for your client app), then you can just use LocalDB or AppSettings, depending on your data structure.
Otherwise, if your application contains more complex features, then you will need an API and a remote DB managed only by you.
To conclude, you only need to setup Sql Server once, when you want to create the design of it (tables, columns, links). The clients will only have to connect to it and pull their data. And this task can be done without installing SqlServer. This link shows you that you only need System. Data assembly to connect to a Sql Server DB.
Yes you need to instal SQL server on each machine or if you go for LocalDB then also u need to instal SQL server engine ,and you have a better option u need to buy sqlserver from AZURE (it's free for one month try if want click here AZURE)

Connect to LocalDB of other system [duplicate]

I am looking into using the new SQL Server Express LocalDB (I think it is code named "Denali") for a desktop application.
It is currently running with SQL Compact, but the user is wanting to share the database between multiple PCs on a network. Unfortunately this is not something that SQL Compact can do, so I am investigating other solutions.
The client requires the ability to send database files easily to other sites or to back them up to a flash disk, so I am avoiding going to SQL Express because there is quite a bit of "administrator" knowledge required to backup and restore.
So, my questions is, does the new SQL Express LocalDB support remote connections to the database over a network and/or through a shared network folder with the mdf file in it?
LocalDB does support supplying a path for an attached local DB in it's connect string (AttachDbFileName) hence the shared network folder option.
NOTE: This question pertains to "LocalDB" the new version of SQL Express 'Denali' and not to SQL Server Express 2008 or prior.
See article here announcing LocalDB's release: http://blogs.msdn.com/b/sqlexpress/archive/2011/07/12/introducing-localdb-a-better-sql-express.aspx
No, SQL Server Express LocalDB doesn't accept remote connections.
The idea with shared network folder might work, but only if you are able to make sure the LocalDB instance is shutdown before you try to copy the file. Also keep in mind that only one LocalDB instance can have any given database file open at the same time. and don't forget about the log files!
Additional security warning: unlike SQL Server Compact databases, SQL Server Express databases (including LocalDB ones) are not designed as secure data exchange format. For instance, they can contain malicious code in .NET assemblies embedded in them. So you should never open databases from untrusted source.
Maybe providing the customer with a simple tool that automates the backup process would be a better idea?
This isn't a fresh thread, but I would like to share my experience with SQL Server Express database LocalDB.
I have a WPF C# project using SQL database with LocalDb Engine. It is working fine no problem, I can use the database with the WPF app. I wanted this app to work on network with more PCs.
On the network another PC can use the database from my PC using UNC path in the connection string.
It seemed to me the remote connection is working. However when the remote PC is connected, I am not able to use the database with my local WPF app. If I run my app first the remote PC could not connect. So this tells me that the remote connection is working, but the multiple connection is not allowed.
OK, I didn't give up and I run the app from my PC twice and I saw it is working which tells me that the same SQL LocalDB engine can handle multiple connections locally only.
I hope this experience will help someone. Thanks.
In short, yes it can. Here is a tutorial on how to configure it.
Also, here is another post with a potential issue that might occur.
Both explain how to configure SQL Server Express to accept Remote Connections.

Easy way to keep two SQL Servers synced if you have read only access to publisher (source) of data

I am making C# app that rely on data from one old SQL Server 2005 machine.
Since I have only acces to read only data from that server, I need to build up some kind of handmade replication.
My app is going to use SQL Server 2012 and I am planing to read data from old SQL server in nightly tasks.
Before I start reinventing the well for sync data between two SQL Servers, I'll love to try to find some kind of library or system which can do the JOB.
Unfortunately I can't just setup replication between two SQL Servers because source of data is at SQL Server 2005 version and I do not have admin rights on that server.
I just need few tables to keep sync (updated) at my new SQL Server.
Is there some kind of embedded replication which can be called from code, and which have no needs for writing and admin access to publisher database?

developing sql application using local database

I am starting an application (c#, .net) that will interact with a Microsoft SQL database. I need the ability for multiple clients to access the data concurrently so I an going to use a service based database (.mdf). Is it possible to develop the application using a local database (.sdf) and then easily switch it over to a service based database when it comes time for deployment? Is that how this type of development it typically done?
You can control the data source by providing connection string to your database in .config file.
You can even create Debug and Release versions of your .config file with different connection strings. Debug can point to your local machine and Release to production.
Development shops vary, but it is pretty common to develop apps using SQL Express locally and then use a full installation of SQL Server for the production environment.
The only thing I would advise is make sure that the DB you chose for your dev environment supports the same features as what you expect in production. For example don't use SQL Express on your dev box when you expect to use Oracle in production.
If the database schema in both backends is exactly the same than the only thing you will need to do is change the connection string when you are ready to move to the service based database.
Be aware that the slightest change in the schema can (and probably will) cause problems.
You want to use SQL Compact Edition (as you said database file extension is .sdf), right? You can use MSSQL Express Edition instead, as it acts more like full MSSQL Server, and is still free and not so hard to install on developer's machine (I personally prefer this option). There are differences between the two (as explained here: http://blog.sqlauthority.com/2009/04/22/sql-server-difference-between-sql-server-compact-edition-ce-and-sql-server-express-edition/). If you don't want features like triggers/procedures/views in your database, you can still use CE, though.
If you have multiple clients then you should use SQL Server Express (.mdf file) - SQL Server Compact (.sdf file) is useful when you are building an application that is going to be deployed on client machines and will run standalone, e.g. windows forms application with a local database. SQL Server Compact is just an alternative for MS Access .mdb files or SQLite, the so called "embedded databases", while SQL Server Express is a real database server (albeit with some limitations to render it unsuitable for large commercial applications) and should be used in the cases where multiple clients use central database, e.g. web applications and smart client apps (the latter could also make use of a local embedded database though).

SQL Server Express / MS Access LINQ Features, Which One to Use?

I have a few ASP.Net database front-end websites where MS Access is the back-end. I am trying to use ASP.Net dynamic data website. Should I change this database to SQL Server Express or something else to make it easier or should this work from with MS Access.
Pick SQL Express for these reasons:
Scaling: MS Access will never scale. Once you get over about 10 concurrent connections you will start to see trouble. SQL Express will scale. You can always move SQL Express up to a full-blow SQL Server installation. While this is somewhat true of Access, some of your SQL statements and data types may not transfer cleanly.
Security: SQL Server has a much better security model than Access. You can lock down the schema in your db per user. You can also better administrate user access (think dev user vs test user vs production user).
Performance: This is similar to scaling. If you see a traffic spike to your web site, Access may not handle it while SQL Server Express probably will.
Tools: Tools and libraries like LINQ are always going to be targeted at SQL Server. You will get better support and better documentation using them this way.
A Jet back end will work fine for mostly read-only websites, even ones with decent traffic. Michael Kaplan's old website, http://trigeminal.com, uses a Jet database as the back end, and back when it was his primary site (he's since been hired by Microsoft), he said it was getting over 100K hits per day, and was holding up just fine.
For read/write operations, Jet will begin to bog down on a website about the same place it would bog down in a multi-user LAN application, at somewhere between 20 and 50 simultaneous connections, depending on your app's design.
For what it's worth, even though I'm a professional Access developer and know Jet very, very well, I don't use Jet as a back end for any of my websites. That's not so much because I don't like Jet for websites, but because I don't like Windows for a web server -- I'm an Apache supporter (and PHP developer), and host all my websites (and my clients' as well) on non-Windows hosting services (presently all of them are Linux, but that wasn't always the case). All the website databases I have ever done use MySQL for the back end.
In short, find out what your host offers in terms of database back ends and choose the best one. I can't imagine a host that provides ASP.NET that would not offer SQL Server, and that's definitely what I'd go with in that situation. It would be easy enough to upsize your Jet back end to SQL Server on your local PC, and then do a backup that you could import to your website.
You can use LINQ to DataSets to use Linq against an Access .mdb or .accdb database.
You can read more at http://msdn.microsoft.com/en-us/library/bb386977.aspx and http://blogs.msdn.com/adonet/archive/2007/01/26/querying-datasets-introduction-to-linq-to-dataset.aspx

Categories