Install SQL Server Express from WinForms on Button Click - c#

Hopefully I am wording/asking this right.
I have a Winforms, .Net 3.5, app that I am trying to allow the user to kick off a SQL Server Express install from a UNC if they are a laptop. I present them with a screen on first run after the Click Once install. This screen asks them if they are a "Mobile" user. If yes then my app sets up the necessary merge replication sets between there local SQL Server Express and the correct publisher. Initially I have just had SQL Server Express be one of the prerequisites.
However this is unnecessarily bloating the install since not everyone needs SQL Server locally. Instead of having two separate Click Once installs I would like to be able to kick off installing SQL Server from an UNC path if they choose Mobile on my start up screen.
It's not as simple as a Process.Start() is it? Oh, this is an internal app only. Everything is done on our network.

It is as simple as Process.Start().
However, you may want to check the installer documentation and pass command-line options for a silent install.

Related

Setting up MySQL server on C# deployment

I have finished developing the first release of my application which uses MySQL (locally under one license and hosted under another).
Connecting the application to the hosted database works fine, i edit the connection details within my application to the hosted server details and it works fine.
However, when I try and use it locally (server:localhost etc..) i get an error stating it can not access the server. In my application, i have included the mysql DLL files, but I would prefer the user not to have to install MySQL server which is about a 100MB download (i know its quite small these days but want the install to be as pain free as possible).
I know it would be an easy fix just to add this install as a prerequisite, but i am sure there is a way to do it without this, or maybe not. Is there a script i can run which will run through and setup the server with users etc?
Any help is appreciated.
Thanks
Shaun
Connecting to a local mysql database implies there's a mysql database service running and was previously installed.
If you want a database you can distribute with your program without having to install a fully fledged database there are quite a few around such as MSSQLCE.
But otherwise, your user is going to have to install mysql on his own machine and keep it running.
Or you could use SQLLite, which is what i have had the best experience with so far.
It should be easy to refactor your Program to use this, and it takes no user setup to use it.
Hope this helps :)

MySQL Error 2003: Can't connect to MySQL server on 'localhost'

I've been given the task of running a program that relies on a MySQL database, specifically, the 3.23.42 version. I have to install MySQL, run a .batch file that reads an SQL file (to create the required tables and such), then run the program. Seems simple enough.
I got as far as installing MySQL. I was expecting it to ask username and passwords and such, as was my experience with installing SQL Server and MySQL version 5 (and later), but it needed nothing from me. Attempts to run the .batch file, however, yields the error:
"MySQL Error 2003: Can't connect to MySQL server on 'localhost' "
So I ran Command prompt as an administrator, went to the MySQL directory, and ran "mysql". It gave me the same error as above.
Running the commands "mysqld-nt" or "mysqld" didn't do anything, so I'm assuming there's another problem at work here. Neither did I find any 'mysql' in the running services or process.
At this point, it doesn't matter if the program runs or not. I need the database up and running first.
Although I've used MySQL before, I can't say I have that much experience with it, and it had always been up and running already; this is the first time I'm deploying it myself.
Of note is that:
I haven't tried to reinstall the program yet, although I'm not sure if it will fix anything.
I've installed MyODBC-3.15.05, if it means anything (part of the instructions).
I'm using Windows 7, 32-bit (I have heard MySQL doesn't like to play nice with Windows 7).
I'm using this setup as both the server and the client; had the entire process been successful, I was to do the same thing on another computer. No computer actually uses another as a server.
I don't exactly know what services to look for in the services list.
Is there anything I can do to fix this problem?
Early versions of the MySQL installer didn't set up the windows service at all.
You might have to do it by hand.
http://dev.mysql.com/doc/refman/5.1/en/windows-start-service.html
When the service is installed you should be able to enter the following command to start the service.
net start mysql
Then all you need is to open a command window and type the following to get you into the MySQL command line where you can start writing your own queries.
mysql -uroot
I'm not terribly up on Microsoft SQL Server's flavour of SQL but I think that if you are used to using it then you might find it difficult to "get into" MySQL.
Here's a simple tutorial that gives an overview of MySQL and creating queries.
http://www.bigsoft.co.uk/blog/index.php/2012/10/04/sql-for-beginners
Check in Task Manager that mysql server is started.
Check if you can connect to the server, run telnet <hostname> <portnumber>, e.g.:
telnet localhost 3306
If you could not connect, try to find server properties (check port number), also check your firewall.
Look for the file my.ini and add bind-address = 0.0.0.0 in the [mysqld] stanza.
Well, I don't exactly know what caused this issue in the first place, but I was able to find a way to solve it. A helpful, if old - perfect in this case - tutorial I found on the web, that hopefully can help others with the same problem.
Tutorial: Install MySQL 4.0 - Windows, by Dr. Thomas E. Hicks
Computer Science Department
Trinity University
Link Here
I'm not sure if the services application is on other windows or not but if you use Windows 7, you are lucky. The easiest method is to open Start panel,in the search box,type services and hit enter.Now scroll down till you find the mysql service.In the latest version, it is named MySQL57. Right click on it and click on start.
Now you are good to use MySQL. However,you will have to perform this step every time the windows starts.
Open the MySQL Installer and click on where it says "reconfigure" next to "MySQL Server"
if it is showing error 2003 (HY000): Can't connect to MySQL server on localhost (10061) than
1.search services.msc in run
2.goto mysql properties
3.copy the mysql service name
4.start cmd as administrator
5.write: net start mysqlservicename .i.e mysql57 or etc
it will show mysql is starting.

How to auto update my application which is developed in c#?

I have developed my application in c# which uses SQL Server Express as a database. I want to update my application through internet. What I want is to update only myapplication.exe
Because in the installed folder there is also application.config where configuration of that server is included such as Server name, Instance name. I do not want to touch this file. It is unique for every machine. Is there any ready mechanism or codes to do that? Please show me directions.
There is the Microsoft solution ClickOnce http://msdn.microsoft.com/en-us/library/t71a733d(v=vs.110).aspx
On the open source side, there is Omaha, from Google, powering Google Chrome, Google Earth etc. http://code.google.com/p/omaha/
Also, take a look at Shimmer, by the folks at Gihub https://github.com/github/Shimmer
Sounds like you need ClickOnce installation.
http://weblogs.asp.net/shahar/archive/2008/01/29/how-to-use-clickonce-to-deploy-your-applications.aspx

Publishing application along with the databse with no need of ms sql on client side c#

I am new here to this forum so mind if I am asking a question already answered somewhere.
I have made an application in windows form, now I want to implement it onto another client PC. I published it and I can install it somewhere else fine, but the problem is that when there is a database involved I just cannot get it to work. I have tried everything I know, I attached the DB with the setup using the setup wizard creator but I cannot get it to work.
My main question is: How can I publish an application successfully, along with its DB and everything in working condition, without installing MS SQL on the client PC, if possible?
Typically, when using SQL Server, you are running in a client-server scenario, and SQL Server is the server portion. The connection string stored in app.config would point to the SQL Server, and the user would never need to know anything more about the database.
If your application is designed to be run outside of the network (i.e. 3rd party), you have a couple of options. First, if you want to use a full version of SQL Server, you can make a client installer and server installer. The server installer would be for setting up the server side (including the installation of SQL Server), and during the client setup, they would need to enter the name of the database server.
If the client has SQL Server Express installed, you can supply the database file, and do a direct connection to it rather than installing it inside SQL. However, if the client does not already have Express installed, this won't work.
Finally, SQL Server Compact Edition is designed for running on the client. You can do a "bin deploy" - that is, copy the SQL CE .dll files with your application, rather than installing the software, and the client can use the supplied database. If you haven't written the application for CE, this would require some rework.
you can also use sqlLite , it just need a bit of modification as it stated by Dave Simione

How to genenerate Database backend during Software installation?

I have developed a small application with SQL SERVER back end and I also make an installer for the application with Indigo Rose Setup factory 8.0. What I need is I want to automatically create the database back end with specific user account during the installation of the application.
Before the installer a user is asked to install either SQL server or SQL express as prerequisite, when the database is installed the installation of the software continues. I tried to do using SQL script but I don’t how to do it before installation on the installer software. I though also to embed the database creation program in the main application and it will execute on the user need upon the completion of the installation but I have never tried it before whether it works or not.
Incase if it need I developed the system using C# with SQL SERVER 2005 backend.
So would you please give me some answer to tackle the problem?
Thank you
The simplest way would be to have the installer call sqlcmd.exe to run a sql script. To call that, you will need to know the data source (location) of the sql instance. You will need to get that from the user. For example, machinename, machinename\instancename or typically sqlexpress is machinename\SQLExpress.
http://msdn.microsoft.com/en-us/library/ms165702.aspx
You can also side step the pre-req and install sqlexpress for your customer. There's a cmdline to install it:
http://msdn.microsoft.com/en-us/library/ms144259.aspx
Another option with no sql dependencies is to write your own custom action (command line/API), parse between the GO statements in the script and execute with ADO.net.
Another option outside of setup is to separate setup and configuration. Setup only lays down bits and the database is created at runtime via a configuration phase of the runtime of the product. This has many benefits including being able to update your bits (either with a patch or automatically) after the setup phase and before the configuration phase. You can also give a better interactive experience and handle issues at runtime - with setup, your choices are to fail setup and roll it back which is a bad experience.
Hope that helps.
Bryan already gave you good advice. My recommendation would be to have the application itself be capable of deploying the database by running the deployment script(s). You can use a library like dbutilscmd that parses the .sql scripts and executes the batches from inside the application. I would also advise to have your scripts be capable of upgrading the database, not just deploy it. This will be very handy when you release v. 2.0 of the application. See Version Control and your Database.
One thing to consider is that often the initial database deployment requires an elevated privilege context. There are some options, see Teach Your Apps To Play Nicely With Windows Vista User Account Control.

Categories

Resources