I have designed an accounts software for my clients. I used SQL Server 2008 database with Stored Procedures. It is developed in Visual Studio 2010, .NET Framework 3.0. I have more than 500 clients using Windows 7.
The major problem is:
Is SQL Server runtime automatically installed with .NET Framework? As MS Access database does not required Office to be installed on client.
I can not installed SQL Server 2008 on each client, it is a tough job. Also the clients are not having a good knowledge of installation process.
How to run SQL Server database on clients without installing its setup on clients? Is there any runtime files or setup?
Option 1 - Setup Project
Using Visual Studio you can create a setup project and install prerequisites that you need during installation.
The installation process is very simple and the end user can install application and prerequisites after clicking next buttons.
Here are the steps for Creating a Setup Project:
1- Create a c# Windows Forms Application
Create a C# Windows Forms Project
Add New Item and Add SQL Server Database to your application
Add a table to your application and fill some data in it
Show the data in your main form.
2- Create a Setup Project
Add new project → setup and deployment → setup project
Right Click on Setup project and Add project Output and select primary output from your main project
Right Click on Setup project and Add project Output and select content files from your main project
Right CLick on setup project and Click Properties and click Prerequisites and select SQL Server Express
Select .Net Framework
Select Windows Installer
Select radio button Download prerequisites from the same location as my application.
Right Click on Users Desktop at left pane and add new Shortcut and select application folder, primary output from SampleApplication, and click ok and the rename the short cut to what you need.
Rebuild solution.
Rebuild Setup Project
Go to Output directory of setup project and run setup.exe
It's that easy.
For more information take a look at following docs articles:
How to: Create or Add a Setup Project
How to: Install Prerequisites in Windows Installer Deployment
Walkthrough: Using a Custom Action to Create a Database at Installation
Option 2 - ClickOnce
Using Visual Studio another option is using ClickOnce publishing.
To do so, in properties of your project, in publish tab, click prerequisites button, you can select SQL Express in prerequisites. This way, you only need to set your database files to copy in output directory, and use AttachDbFileName in connection string: Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|\Database.mdf; Initial Catalog=Master".
For more information take a look at the following docs article:
How to: Publish a ClickOnce Application using the Publish Wizard
LocalDB is Microsoft's current recommended solution. It allows you to connect to a database file directly, without having to install an instance of the Full SQL Server, or SqlExpress. It is fully compatible with the full version of SQL server. There are no installation requirements on the client end, as the libraries are packages along with your application when it is built.
You can read more about it here.
you can instal sql express With silent installation in your setup
this way not showing any wizard for install sql express
Read this Link
Related
I want to create a setup file from a C# project in Visual Studio 2015 that attaches a SQL server database, and I want to run that setup file on another system and run without Visual Studio and SQL server
You are have two solutions
You should develop your application with SQL express on .NET framework or after develop with SQL Server change connection string from SQL Server to SQL express and rebuild it, be sure you create initialize DbContext class to set some data for run your application at first time with base and default data. [Such as application users and rolls and groups].
You should develop your application with dependency injection pattern [Microsoft Unity, IoC] then modify or replace one interface to change your developed application database.
Then Right click on project in solution explorer and publish it and give to customer.
The customer server has to run some kind of SQL Server if you want the SQL data to be accessed somehow. One thing you can do is to deploy your C# project with Visual Studio, export all needed tables (including their data if you want that) from whatever server you are using (for example MySQL) into a .sql file and pack everything, including instructions on how to install the sql server and your application, into a zip file and ship it to your customer.
What I do with my website application is, that I include a .bat that fetches everything from my git repository, deploys my web application on an existing IIS-Server on the current computer (with 'aspnet_compiler -f -c -u -errorstack -v /web -p "source directory" -d "target directory"' and 'iisreset /noforce') and automatically imports the SQL tables to an existing MySQL Server (with mysql --host=localhost --user=user --password=password --database=database < Backup.sql).
Sorry for that general answer, but you're question really wasn't that precise.
If you want to create a setup of your project then,
Click on Build on the top of visual studio tab and then click on Publish "yourprojectname" click on it and your setup file will be ready.
Hope this helps you
Use LocalDB,
(no need to at least open sql server management studio)
When you create Setup file add prerequisite
.net framework version
sql server (2012 -2019) express localdb
Add connection string correctly!
So from what I can gather you are looking for an easy way to distribute your database schema to clients, is that correct? If so then I don't see how you could intend to run the setup without SQL Server (without VS is fine though).
Assuming my assumption is the case then I think you need to think about a solution that will handle schema upgrades as your project develops, in which case it's essential that you move to Database Projects in Visual Studio as it will handle upgrading the schema automatically, and allow you to run change scripts for the things it can't do automatically (like when you've changed a column type or removed a column etc).
Here are some links to get you started:
Working with Database Projects (MSDN)
Introducting Database Projects for Visual Studio (youtube)
Using the knowledge that CSPROJ files are just MSBUILD scripts at the end of the day you can now publish the database project during whatever your installation/upgrade system is using msbuild which is included in the .NET framework i.e. you don't need Visual Studio.
This is by far the most robust and reliable way of dealing with database deployment. I would advise staying well clear of automated tools like Redgate, they do a great job for small projects that maybe get used in an office etc but for professional software development you need more guarantees and control.
You can try this, with Octopus deploy.
Or, you can try with Code First migration
Have you already existing database, or development starts now?
I am using visual studio 2013.
I have done
File -> New -> Project
I then choose Template -> Visual C# -> Web -> ASP.NET Web Application
Project name is set to WebApplication1.
When I press F5 to run the website it becomes a basic working website which user can register an account.
The problem that I am facing now is that how do I access the database that store the registered users? How can I manage the users? I intend in the future to publish it into a website. I need to find a way to backup the users.
Should I need to add in my own tables should I put them in a separate database or should I store it together with the database that comes with the project?
I cannot find any information on this. I suspect the keywords used for searching might be wrong. Can someone give me some suggestions?
The default template for asp.net creates a database to localdb which is a light version of sql server and will be installed with visual studio 2013, to see the generated database, browse to the AppData folder in your project and you will find a long file which contains some of your project name, this is the generated database. Now you can attach this db file into sql server through management studio if you have one or you can change the connection string to the sql server instance that you want with the database name that you want and rerun the application and you will get the database generated into the sql server that you set where you can do anything like any other database.
EDIT
If you run and registered successfully one user in your application the database will be output there, there is a small icon in the solution Explorer in vs 2013 that shows the all files (hidden) files, as the database is not part of the solution. Try that icon and you should see the database file there.
Hope this helps.
The mdf file will appear in AppData folder once I register a user.
I am working with visual studio 2013 in c#. My application contains three project in the same folder: client side, database side and web service side.
When I run the application from within visual studio, it runs very well and all the features of the application are functioning. When I run the exe file located in the bin/debug folder, it runs only when VS is open. If VS is closed it runs only the client side and a message is shown
impossible to connect to the server.
How can I solve this?
When VS is open, it runs the server/web service, and your client. Running it from the commandline will require starting your server and web service side manually, and then starting the client.
If you don't have IIS manager installed you can launch IIS directly from iisexpress.exe.
It should be in C:\Program Files (x86)\IIS Express\iisexpress.exe, so just go ahead and run it.
Then you should be able to run your application.
To start IIS from the IIS manager go to Run (press Windows+R), and type in inetmgr.
This will open IIS manager, from there you can start it (forgive me for not being too specific, I don't have it currently installed. I believe you have a Start button at the side-panel. I hope someone in the comments could chime in or just edit this answer. If not I will install & update later).
After it is on you should be then able to run your executable successfully.
If your command-line can't find inetmgr, see my other answer here.
However if you do want to have the IIS manager you can install it + other IIS features easily:
Go to Computer → Uninstall or change a program.
At the side click on "Turn WIndows features on or off".
Inside "Internet Information Services" have your pick of whatever you want.
When you run in Visual Studio 2013, by default it uses its IIS Express as a webserver. You can set it to use IIS instead. (If you don't already have IIS installed, you'll need to install it using add/remove Windows components etc--google for more info on that if needed. Make sure you drill down to include ASP.NET under the IIS bits and pieces.)
To use IIS instead of the Visual Studio development webserver, right-click the project in Solution Explorer, and click the Web tab:
Select External Host in the dropdown, and enter a URL such as http://localhost/WebApp1. This is the virtual name by which IIS will access the files in your project folder. Earlier versions of Visual Studio included a button to create the virtual directory, but in 2013 you must create it yourself by running IIS Manager:
Enter the same virtual name you use in the project settings, and the physical path of your project:
Finally, right-click the newly created virtual directory and choose Convert to Application.
The website/webservice will now run under IIS, so will be available independently of Visual Studio.
I'm working on a C# project for windows mobile 6.5 and as of this morning I'm getting "Reference package not found. Device Connectivity Component" whenever I try to deploy.
It builds without errors and was working up until today. I did a bit of looking around and only found dead ends online. As far as I can see there are no clues about that component or package this is a reference to. I think it may be related to Windows CE SQL Compact but that's based on nothing. I've rolled back to an earlier version of my code and cleaned a few times. I'm stumped.
I would greatly appreciate any help even diagnosing this a bit further. I'm using Visual Studio 2008 3.5 SP1
Update: When I disable "Deploy latest version of the .NET Compact Framework (including Service Packs)" it does deploy but then throws errors related to the SQL database which worked previously. assumedly because it doesn't have access to the correct SQL packages.
Update: I also get the same error with the emulator, it builds, the emulator starts but can't deploy, giving the same error.
Update: I think this might have something to do with it. Note the double slashes in the path. I keep removing them. It keeps coming back.
Update/Correction: I can now deploy to the emulator, I had a problem before but it seems to be ok now. I still can't beploy to the device, same error.
For anyone who was pulling their hair out like me. I couldn't figure out what was wrong although I still suspect it was something to do with the .NET compact package. Eventually I created a new project, set up the references and copied and pasted the code over. It's not a nice solution but it worked after days of being stuck.
HA! I found it! This may not be your solution, but this was how I did it.
See this REF: http://msdn.microsoft.com/en-us/library/aa983326(v=vs.90).aspx
Since Microsoft is bad about deleting their old info, I'm going to post it here, too. But basically, if you select a Private Deployment, then Microsoft Updates will not influence your project or update your 3.5 databases to ...whatever the newest stuff from Microsoft is.
How to: Deploy a SQL Server Compact 3.5 Database with an Application
You have two deployment options for applications that contain SQL Server Compact 3.5 databases. The method of deployment you choose depends on the servicing requirements of your application and whether your users will need administrative credentials on the computer on which the application will be installed.
Following are the deployment options for SQL Server Compact 3.5 databases:
Traditional Microsoft Windows Installer (Microsoft setup technology)
Users need administrative credentials to install the application.
SQL Server Compact 3.5 will be serviced by Microsoft Update.
Can use ClickOnce deployment.
-or-
Private file–based deployment (deploying the SQL Server Compact 3.5 DLLs as part of the project)
Users do not need administrative credentials to install the application.
SQL Server Compact 3.5 will not be serviced by Microsoft Update.
Can also use ClickOnce deployment.
Traditional Windows Installer
Traditional Windows Installer technology is used in both standard Setup and Deployment projects and in ClickOnce deployment. When you deploy a SQL Server Compact 3.5 database, ClickOnce deployment provides an option that automatically installs SQL Server Compact 3.5 if it is not detected on the target computer. For this reason, ClickOnce is the preferred method of deployment for applications that include SQL Server Compact 3.5 databases (as opposed to creating a custom action in a Setup and Deployment project).
ClickOnce deployment has been updated so that it automatically includes the SQL Server Compact 3.5 runtime as a prerequisite for applications that include SQL Server Compact 3.5 databases. It also recognizes .sdf files as data files and sets these to the correct publish status.
Creating a ClickOnce deployment for an application that contains a SQL Server Compact 3.5 database consists of configuring the proper publish information in the Project Designer.
To use Windows Installer technology for ClickOnce deployment of an application that contains a SQL Server Compact 3.5 database
To open the Project Designer, in Solution Explorer/Database Explorer, double-click My Project if you are working on a Visual Basic project (or Properties if you are working on a C# project).
Click the Publish tab.
Click Application Files and set the .sdf file to Data File (Auto). (This setting notifies the installer to treat this as a local data file and to put it in the Data Directory.)
Click Prerequisites and select SQL Server Compact 3.5. (This setting notifies the installer to check whether the SQL Server Compact 3.5 runtime exists and to install it from the Internet if it is not found.)
Creating the Installer After the publish information is configured, create the installer.
To create the installer
In the Publishing Location box, type the Web site, FTP server, or file path to publish the installer to.
Click Publish Now to create the installer.
The application is ready to be installed. Go to the location you published to, and install the application to verify.
Private File-Based Deployment
Private file–based deployment refers to the process of including the required SQL Server Compact 3.5 DLLs as files in the project (as opposed to a reference to DLLs already on the target computer). If you include the necessary DLLs with the application, the requirement to install SQL Server Compact 3.5 is removed. Therefore, the administrative credentials are no longer needed.
You can use ClickOnce deployment technology for private file–based deployment. If you do, you must remember to clear the SQL Server Compact 3.5 prerequisite so that the Setup program does not install it.
To deploy a SQL Server Compact 3.5 database by using private file–based deployment
To open the Project Designer, in Solution Explorer/Database Explorer, double-click My Project if you are working on a Visual Basic project (or Properties if you are working on a C# project).
Click the Publish tab.
Click Prerequisites and then clear the check box for SQL Server Compact 3.5.
Close the Project Designer.
Go to the directory that contains the SQL Server Compact 3.5 DLLs. These are located in C:\Program Files\Microsoft SQL Server Compact Edition\v3.5.
Select the seven SQL Server Compact 3.5 DLLs and copy them:
sqlceca35.dll
sqlcecompact35.dll
sqlceer35EN.dll
sqlceme35.dll
sqlceoledb35.dll
sqlceqp35.dll
sqlcese35.dll
Paste the DLLs into the project in Solution Explorer/Database Explorer.
Select all seven DLLs in Solution Explorer/Database Explorer and open the Properties window.
Set the Copy to Output Directory property to Copy if newer. (This will replace any earlier DLLs in an existing application with the newer ones if the application is updated.)
Click the Show All Files button in Solution Explorer/Database Explorer.
Expand the References node.
Select System.Data.SqlServerCe.
Set the Copy Local property to True. (Because your development computer has the SqlServerCe DLLs in the global assembly cache, you must configure the application to use the DLLs in the output directory.)
Right-click the project in Solution Explorer/Database Explorer and select Publish to open the Publish Wizard.
Complete the wizard to publish the application.
The application is ready to be installed. Go to the location you published to, and install the application to verify.
I had the same problem. I got it to work by closing visual studio, renaming the directory:
C:\Documents and Settings\\Local Settings\Application
Data\Microsoft\CoreCon
Then reopening visual studio and the deploy worked.
I created a new Visual Studio Setup project with VS 2008.
I use it to install SQLExpress.
The installatino of SQLExpress works fine when I do it manually outside of the installer.
But when I install, I get an error in SQL Express with permissions.
I found out that it's because the SQLExpress process is running as the System account when I run it from my setup project.
I tried starting the process both via custom actions and via C# code that runs after a module is installed via Process.Start.
But both of them run the SQLExpress process as the System account.
What can I do to run this process instead as the currently logged on user?
Note: I also tried to start calc.exe and that runs as the system process as well. Why won't it run under the context of the same user as my installer is running as?
If you want to install SQL Server Express as a prerequisite to your application you should add it as a prerequisite to you Setup and Deployment project.
This can be done by right-clicking on your setup project, then choosing Properties -> Prerequisites and then checking SQL Server Express 2008.
Note that in order to have SQL Server Express available in the list of prerequisites it must be installed on your development machine.
Update:
If you want to specify an instance name there is no way around manually editing the bootstrapper package definition.
For Visual Studio 2008 the bootstrapper packages are placed in the following location by default:
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages
There you will also find a folder names SqlExpress. Within that folder, open the file en\package.xml and modify the command line arguments for the installer. There are three sections depending on the target OS (Win 2000, XP and 2003+):
<Command PackageFile="sqlexpr32.exe"
Arguments="-q /norebootchk /qn reboot=ReallySuppress addlocal=all
instancename=SQLEXPRESS SQLAUTOSTART=1 ADDUSERASADMIN=1"
EstimatedInstalledBytes="225000000"
EstimatedTempBytes="225000000"
EstimatedInstallSeconds="420">
...
</Command>
This change will affect all installers with this package as a prerequisite that are build on your system. If you don't want that you would have to create your own separate bootstrapper package by copying the SqlExpress folder and updating the ProductCode in SqlExpress\package.xml.