ClickOnce application using SQL Server database - c#

I'm trying to learn how to create a simple application using Visual Studio IDE in C#.
I wrote a little application that uses a local SQL Server database for reading and storing data. On my machine, the program seems to work normally, but when trying to install the application on client computer it seems unable to read from the database.
I've tried to include the following prerequisites to the publish properties but it doesn't work:
Microsoft .NET Framework 4.5.2
SQL Server 2012 Express LocalDB
Any ideas about the right way to do it?
Thanks to all.

You need to install SQL Server Express LocalDB (SqlLocalDB.MSI) on the computer you are deploying your ClickOnce application to.
Selecting "SQL Server Express LocalDB" in the Prerequisites window and using "Download prerequisites from the component vendor's web site" should take care of that:
If you do that it should install the LocalDB for you and any database errors are more than likely resulting from connection string errors or leaving Integrated Security enabled.
You need to test on a target computer which does not have "SQL Server Express LocalDB" installed and verify that after the ClickOnce deployment it is installed. This will confirm that the problem is not the missing prerequisites but the database access issues...

Related

Connect Windows Forms application with SQL Server Express

I have created a Windows Forms desktop application using Visual Studio 2019. I also created a database using SQL Server Management Studio. I connected the database with my application with connection string
"Data Source=CYBERCELL\\SQLEXPRESS;Initial Catalog=Details;Integrated Security=True;"
The application is running without any error. I published this application using Visual Studio 2019 publish wizard and installed in another computer. But I can't understand how to use and connect the database with the application in that system.
I am looking to install SQL Server in every computer. But if I install SQL Server, the server name will be different.
If you're locally installing SQL Server Express on each individual computer, you could use
.\SQLEXPRESS
or
(local)\SQLEXPRESS
as your server/instance name - this is the same on every computer. The dot . or (local) (in parenthesis) refers to the local computer, and SQLEXPRESS is the default instance name for any SQL Server Express installation.
I once stuck with this same scenario... and this is how I solved the problem,
You don't have to install SSMS or SQL server on any of your client's pc, if you follow these steps
You have to create a localDB on your application and make sure the application will connect to that localDB.(if you don't know how to connect to local db, here => Connect to LocalDB. And make sure to create tables and procedures as same as your previous database.
Follow this answer(ticked) with code(connection string)
After this, you have to install Advanced Installer to create an installer for your application (the best choice I ever chose).
Then Follow this to create an installer where you make sure to add a prerequisite of localDB (say localdb 2019) installer of your current version.
This makes your application run on any pc and only requires localdb as a prerequisite to be installed which also comes with the installer.
Make sure to leave a message not to delete localdb on the application installed location.

How to run desktop application with database locally without installing any database Server?

I wanted to create a desktop application with database, am using Visual Studio 2013 and C# , Can anybody suggest me what server I used to create my database, in order to run my application in my client's system locally with out installing any database server in client's system [ie, with out installing MsSql server or MySql server or Acess], I want my app works properly when installing my own application's exe file ?
And Now am using MSSQL server with my application , Is there any way run this application in client's system locally with out installing MSSQL Server? [my application front end works when I install .Net FrameWork 4.5 , I need something like this for my .mdf databse in Sql Server]
somebody says about SQL Server Compact ,but i don't know how to use it
You can use SQL Server Compact, which can either be installed separately or deployed as part of your application.
See here: How to deploy SQL Server Compact Edition 4.0?
And here: https://msdn.microsoft.com/en-gb/library/aa983326(v=vs.110).aspx
Your DB code in your app - apart from your connection string - should not need to change as you're already using some version of SQL Server.
There is also SQLite, which is as far as I know is well regarded, but I know very little about it. http://www.sqlite.org/
Hope that helps!
It is not unusual for an application to require an existing functional database server. Of course this is appropriate only if your target audience is technical enough to install the prerequisite on their own, or if the target environment is guaranteed to already meet your prerequisite.
If not, you need to fall back to an embedded database.

Include SQL Server Express in setup project

I create project in Visual Studio. My app use .mdf files. I created a setup project using InstallShield. On my computer where I developed my app, setup works just fine!
But when I install app on another machine I get an error
you need install SQL Server Express
How to embed SQL Server Express into my setup project?
You need to install SQL Server on your computer, Visual Studio can not embed this. Go to https://msdn.microsoft.com/en-us/sqlserver2014express.aspx, download and install. I'm not sure if you can get it without a Microsoft account.
By using .mdf you got a dependency on SQL Server Express (at least). You might want to pack your database to a server and have your app just use client libraries or you could switch to SQLite or something with less footprint.
Also take a look here how to bundle your setup with SQL Server Express:
Can I deploy SQL Server Express with my desktop application just like builtin database?
Visual Studio publishing tool can do that. If you're required to use InstallShield, there's a guy who ensembled a video guide: http://www.installationdeveloper.com/3356/how-to-install-sql-server-2008-express-r2-in-installshield/

LocalDb in asp.net project require some configurations to run on other machine? VS2012

I need to send a asp.net demo using SQL Server database. Is local db something require no configuration to run on other machine ? Is it something if I include in project, on other machine other person will just run application in Visual Studio and LocalDb will be available there ? or it will require some configurations on other machine as well ?
I m looking for a way there I can just add a database in my asp.net application and on other machine having visual studio should open and run it without any configuration. Please guide is LocalDb for this purpose or I should use any other solution ?
Yes, the target machine should have SQL Sever Express 2012/2014 LocalDB installed. It comes with VS 2012 (as long as it was not deselected in the advanced options during setup).
Read more at confusion about SQL Server Express and localdb
If you provide a demo for developers, you should list all requirements for the system, such as
VS.NET version
database engine version
user rights, folder structure, etc.
and they should take that into account when setting the demo.

Deploying Windowsform application with SqlServer 2012 Databse in Visual Studio 2012

How can I deploy a windows form application with sql server database. I've searched a lot, The problem is I want the actual .mdf file when the application got installed on a PC for backup purposes. When I tried the publish feature, it converts the .mdf file into .mdf.deploy. I don't want to attach it into Sql Server Management Studio. I want to publish it with the actual application as .mdf, Kindly guide me in right direction. Thanks
If you nose around on the MS SQL Server site, you find that you can include a 'silent installer' for SQL Server in your .NET project. This will download and install an instance of SQL Server Express as part of your installation process. Just having the .MDF in a folder is useless.
In effect, you have to make at least a few items of functionality that stand in for SSMS: in particular database backups, database compaction, DBCC CHECKDB, etc. You are installing a 'full blown' SQL server instance, with it's separate windows service and system account, so you should be aware of how that impacts your user machine. This gets interesting if it's being deployed to a laptop, particularly a laptop that might sit in a café exposing ports to public LANs.
In general this is a can of worms. It is better to mandate the installation of SQL Server Express first, with SSMS, and merely attach your database to the existing instance. This makes a lot of other operations better behaved.

Categories