PDA

View Full Version : How do I install a MS SQL Database?



KeithK
12-31-2008, 03:49 PM
I'm probably making this a lot harder than it needs to be.

My problem is, that I am trying to install a database into MS SQL Server and there are just too many points of failure I'm running into.

First point of failure is SQL Server detection, the most robust way I have found is to do a system scan for osql.exe, because I use this application later. Registry keys are unreliable, I am not doing a remote installation.

Next issue is authentication mode for SQL Server, Windows Authentication vs Mixed Mode (SQL Server and Windows Authentication Mode).

Next issue is the server that osql.exe connects to, some machines have disabled the name localhost for security reasons, so I can't just assume localhost.

So I have set up dialog screens that prompt for user or mixed mode, the server name and then I install the database.

I install the database by running a command like this:
%OSQL%\osql.exe -s %SERVERNAME% %AUTH_STRING% -i "%CURRENT_DRIVE%\server\install.sql"

%SERVERNAME$ = localhost
%AUTH_STRING% = -E (Trusted) or -U%USER% -P%PASS%

My issue is, if the script runs, I have no way of getting feedback that I actually got an error, or is there? So is there a way I can get some sort of notification of an error so I can report it back to the user and cancel the installation?

And am I making this too difficult by running everything command line, is there a better way to connect to the database?

Honestly, I'm a Java programmer, I haven't written a single windows application in my entire life, I want my installer to look professional and not a hack job, so I'm looking for overall robustness as well.

Thanks
-Keith

linder
01-02-2009, 08:29 AM
Keith,

To get "feedback" from your call to osql.exe, you can use the "Run Command Line" or "Run Program" script functions and mark the "Wait for Program" checkbox. When osql.exe terminates, you should have a return value in the %_SB_ERRORCODE% runtime variable.

Does this help?

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner