I've built a Compact Framework application to be used by delivery drivers. The system includes a WCF Service and SQL database on the server as well as a SQL CE database and CF application running on the mobile device.
Now the question is how to I update all this easily when I release new versions? The problems are:
it may be deployed to hundreds of PDAs
when first installed on a PDA the SQL CE database has to be populated. This can take a while. I don't want to have to do this each time the app is upgraded so I'm going to have to run scripts to update the db schema rather than just replacing the whole file and repopulating it.
the WCF service code will need to be updated
the SQL database schema will need to be updated
I can see solutions to all this but it seems like a lot of work. I thought it may be helpful to get a few tips before I launch into it all.
Thanks a lot
Mark
I've done some projects with more or less the same requierements.
it may be deployed to hundreds of PDAs
I'll recommend to use an updater, within the application. It checks via a webservice the availability of a new version. Download if theres an update. Then run another process to perform the update(This process I only use to run wceload.exe and then reboot the device).
when first installed on a PDA the SQL CE database has to be populated. This can take a while. I don't want to have to do this each time the app is upgraded so I'm going to have to run scripts to update the db schema rather than just replacing the whole file and repopulating it.
Don't include your database as a file for the application, create the scripts and check if the db exists if not create the db.
the WCF service code will need to be updated
I have an update webservice which is independent so the contract wont change. Which receives the current version, authentication and returns if the update is available and the url for the file to download.
You will need two different address to update and keep the other part working.Just perform a redirect in the new version.
the SQL database schema will need to be updated
I hope you mean that you refer to the server backend so I recommend to use views to search for the information.
If you mean to the SQLCE db you can ship patching scripts or plain erase the db and recreate the db.
Related
I'm very new to App deployment. This is my first one actually.
I developed an app which uses a SQL Server database to store its data. I created the SQL Server database with a script. However, neither the script nor the DB itself are part of the "package" of the app. I simply installed SQL Server Management Studio with the default settings, created a new file starting with
USE [Master]
GO
CREATE DATABASE [Database]
and filled up all the details.
The app works in my machine of course, but when I Published the app and got the .Exe, it doesn't work in any other computer, of course because it's not creating a Database to go with it, and the connection string that it uses for the queries is the one that I gave it from my SQL Server instance.
So, I want to know how to actually include the database (or a way to create it) in the "installation package", and also for the program to dynamically get the necessary connection String to operate on any computer where its installed. Right now, I AM fetching the connection string from App.Config with the ConfigurationManager, but of course, the Connection String in App.config is the one that got added when I added MY instance to the project.
Any sort of guidance would be appreciated. I searched related questions but the only ones relevant had some deprecated methods. It's still not very clear to me how it would get the connection string dynamically if its not going to be the same instance.
On a semi-related matter...I noticed that my app was being executed with just double clicking on "setup.exe". Setup seems to imply that it will only install it and add an executable...it's kind of misleading to execute the app itself from the setup, isn't there another way to change that?
Environments
SQL Server 2008 R2
Windows Application in C#
Scenario
I have the desktop application which uses SQL Server. The application deployment builds consist of two scripts #1 Create and #2 Update scripts for deploying the database changes. If creating a new database, it will use #1 script. If updating an existing database, it will use #2 script. There is never a need to run both.
The #2 script – is tied to the Version of the Application Code.
This perfectly fine when the individual user is using a local SQL server.
Problem
We have a client who is using a Central SQL Server where the database is created and individual users connect to same by the desktop application.
Let us say the client is running Application build 02.12.15.140 and the expected database version number is 1.2.45. This week we released to them a new build 02.12.16.310, and in this version, the database version number is now 1.2.51. If a user installs build 140, they will be prompted to update the database with the new #2.sql script, which will change the database version number to 1.2.51. If another user tries to run build 140, they will be unable to connect to the database since application build 140 expects database version 1.2.45 but the database will have been updated to version 1.2.51, due to a central server. Because of this, all users must be on the same client build in order to use the database.
Our challenge is that sometimes to implement new feature or defect, we need to change the database, anywhere from a table design change to a stored procedure change. So new client software versions require an update to the database. We want to make sure that the client software is using the correct database design, so we’ve tied the client software to a database version number. This allows us to ensure that the database design matches what we expect. But it also creates the inconvenience of forcing all users of a database to update the client software at the same time.
Is there is any solution for deploying database changes in such an environment?
I know this is kind of a stupid question but it gives me a lot of problems. Me and my partners in college projects have a lot of issues making the database mdf work when we send each other the visual studio projects. It gives us errors about the versions of sql server. Is the only solution to this to install same version of sql servers for the entire team or is there some other workaround?
Yes, you must be using the same version of SQL Server across all PC's.
You can never "go back" in time with a SQL Server database - once a .mdf file has been attached to a given version, it can never be attached to an older version anymore. And you cannot get around this by using the database compatibility level, either - the internal database file structures are just too different between versions, and no backwards "downgrade" path is provided.
One way to get around this would be to have a common, shared server somewhere that everyone can connect to and everyone can work with - making in unnecessary to send around "free-floating" .mdf files altogether... after all, it's SQL Server - a server-based system - not so much a file-based "database" system ....
Another way to go would be to stop sharing the binary .mdf file, but instead work with SQL scripts that you can exchange within your team, and that each team member can execute locally on their respective SQL Server instances - regardless of their local version
I suggest that instead of passing around mdf files, every person on your team creates the DB and then uses SQL scripts to create the objects. These scripts can be very easily created and exported from the SQL Server Management Studio.
This has the added bonus of being able to put the scripts under version control as part of the project.
I made such practice, with one way , by create separate pc running under windows server, only using as sql server to store all data record , then the data is called via "connectionStrings" of IP with server name of user policy, which is also secured by password and username , so this practice is used , to enabled two different programs to share that data , for example , that I made ( one web localhost app to create internal registration ),( the other web app using to access to mainpage via Login form).
I have a local database I am working on for a website, I can publish the website changes to azure but cannot see an easy way to just get my 'changes' pushed up to SQL Azure.
I used this https://sqlazuremw.codeplex.com/ to initially get my local database onto Azure, but it seems to only support entire database migrations. Not minor changes like data, or a new field added?
This is my first time using Azure and it seems great, it's just this issue with the database which is now putting me off slightly.
I'm afraid that without any third-party tool you will not be able to achieve much.
What I usually do is create migration sql scripts and run them directly against the production database after the scripts have been thoroughly tested
If you manage your database schema using Visual Studio Database project then you can sync it with the SQL Azure database. I believe you can also sync data but I have not used that.
How can I make a program use a SQL Server database, and have that program work on whatever computer it's installed on.
If you've been following my string of questions today, you'd know that I'm making an open source and free Help Desk suite for small and medium businesses.
The client application.
The client application is a Windows Forms app. On installation and first launch on every client machine, it'll ask for the address of the main Help Desk server.
The server.
Here I plan to handle all incoming help requests, show them to the IT guys, and provide WCF services for the Client application to consume.
My dilemma lies in that, I know how to make the program run on my local machine; but I'm really stumped on how to make this work for everyone who wants to download and install the server bit on their Windows Server.
Would I have to make an SQL Script and have it run on the MS SQL server when a user wants to install the 'server' application?
Many thanks to all for your valuable time and effort to teach me. It's really really appreciated. :)
Edit:
To clarify, each business will have their server completely separate from me. I will have no access whatsoever to them nor will they be in any way connected to me. (I don't know why I should clarify this :P )
So, assuming the have ABSOLUTELY NO DATABASE SERVER installed; what can I do?
Ok, part of the answer, dealing with the SQL Server Database (and frankly SQL Server Express will take you a long way - 4Gb of data) and the server install elements.
Firstly make installation of the SQL an SEP, make it a pre-requisite possibly tweak your installers to test (challenging) but substantially point them at the links to SQL Server express and let them get on with it).
Secondly separate installers, as suggested, for your client and your server elements.
Finally, how to build the database - I'd suggest using code to create and maintain (update) the schema i.e. once you have a connection to a server you can run code that calls DDL that does what is necessary (something like suggested here: How to create "embedded" SQL 2008 database file if it doesn't exist?)
A question - are you intending all communications from the clients to go through you WCF service?
Your install application should:
Obtain a SQL Server name, a username (with apprpriate rights to create a database) and password.
Either run SQL scripts using the locally installed command line tool or from code using SMO (for instance), against the user supplied server with the supplied credentials.
BTW, Before you expend effort writing an open-source help desk, have you checked what is already available? Also, Open Source Helpdesk
It is not so straightforward to deploy a client/server solution with an automatic installation.
You probably would then be better off to deploy your server installation together with a database engine and a skeleton database already setup according to your wishes. This is to avoid tampering too much with the existing server - who knows whats on it.
Also you say you want to install WCF services, well this would probably mean installing them on a customer server, in theory this shouldn't be a problem however in reality it could be, depending on what is previously on the server.
Do you want a single SQL Server instance running on your machine, or one on each of your customers' servers? If it's the latter, you'll want to install a SQL Server instance - anything from the (free, but limited and not open-source) SQL Server Express to a more expensive SKU - on each server. You can include this step in your server installation package; MSI installs make it very easy to bundle a MSSQL install.
Then you'll need to drop a schema, and maybe data, on the instance. You could do this as a step in your installer, or as part of your application setup process. It possible that a SQL Server instance, or more than one, might already be installed on the server, and your post-install step should allow the user to specify which instance on which to install your pieces.
Then, include a database configuration piece in your client application. Ask the user - or take from a configuration file at client install time, to allow for unattended or unprompted client installs - server connection details, like server name and authentication information.
A word on authentication - since you appear to be building Windows-based tools, use Windows integrated (domain-managed) authentication if at all possible. Don't get in the business of storing logins, but instead rely on the existing domain to manage logins. A good strategy is to use active directory groups to manage access. Grant access to a particular group in SQL Server, and defer group membership to Active Directory itself. If you can't gain the access necessary to do this, then grant permissions to AD user accounts themselves. Avoid creating SQL Server logins, the use of which open the door to some possible security problems.
I understand what you are trying to do. If I were you, I'd do the following:
Provide 2 downloads - 1 for client and 1 for server.
Forget about MS SQL Server and perhaps go with MySQL, since it really is open source. You could probably get away with using MS SQL Server Express Edition, but if your data set gets gigantic large (which is common with help desk databases), you'd be stuck.
As other people pointed out, on very first run (or at setup time), I'd have the client app locate the server.