views:

90

answers:

5

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.

  1. 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.

  2. 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?

A: 

Your install application should:

  1. Obtain a SQL Server name, a username (with apprpriate rights to create a database) and password.

  2. 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

Mitch Wheat
Yeah, checked them all out. This is mainly an exercise for myself to start building my portfolio but also, I truly want to build something that doesn't require people to read usage guides. I know this is a truly daunting task but it's one that I really feel good about. :D It's my dream.
Serg
A: 

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.

Michael Petrotta
from the question, it appears he is talking about a single instance of sql server ...
Mitch Wheat
@Mitch - You might be right, but I'm not so sure. Note he's building help desk software, something that enterprises often like to run internally.
Michael Petrotta
Yes. They run SQL Server internally on a central server, not on the local users PC...
Mitch Wheat
@Mitch - yes. I'm assuming he'll have separate installers for the client and server, but I should make that more clear.
Michael Petrotta
A: 

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.

Anders K.
A: 

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.
AngryHacker
A: 

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: http://stackoverflow.com/questions/1715691/how-to-create-embedded-sql-2008-database-file-if-it-doesnt-exist/1716021#1716021)

A question - are you intending all communications from the clients to go through you WCF service?

Murph
Yes, everything will be handled through WCF.
Serg
Ok, I'm not convinced that that's the best way to go (-: But it does have certain advantages. All you have to do is ensure that your service and your database are in sync so its only one app and you could therefore include configuration/upgrade of the database schema within your setup process.
Murph