简体   繁体   中英

How to run desktop application with its Sql Server database on a machine that have not SQL server installed

I have already finished a desktop application using Visual Studio 2010 and SQL Server 2008. it's working perfectly on my machine (i have a SQL Server 2008 and 2005 ). the database is local and unchangeable, i want this application to be run successfully on the machine that doesn't have SQL Server installed.

my Connection string is:

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\KBank.mdf;Integrated Security=True;User Instance=True;Connection Timeout=300

I want to know the best and simplest way to make it. thanks

The simplest way would be to create a setup for your application that states SQL Server 2008 as a prerequisite. That's it.

For further help you would have to supply more information on how you use the database in your application and if you have a way to host a public sql server instance to which your application will connect.

If you're using the AttachDbFilename=|DataDirectory|\\KBank.mdf;User Instance=True approach, then you have no choice but to install SQL Server Express (and no other edition!) locally on that / every machine that is supposed to use your application.

This approach is severly flawed in my opinion, and it limits your flexibility.

What I'd suggest is to use the real server approach: put your database onto a server (both on your development environment, and in production) and then you have the flexibility of having either a SQL Server instance on every user's machine (if that makes sense), or you can have a centralized server which the clients only connect to (no local database server installed).

If the database is "local and unchangeable" how about the compact edition ? That way your clients dont need to install a full sql server instance

I agree with Nick. if you dont want to install SQL Server on the machine then SQL server compact edition would be one of the option. Syntax is pretty similar to SQL Server but it comes with limitations. like you can not have a stored procedures in compact edition and few more.

You might want to visit SQL CE Tutorial as a development resource.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM