Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Setup Related Question

  Asked By: Rani    Date: May 22    Category: Asp.net    Views: 709
  

Recently I downloaded and ran a .net setup and I noted that at a certail point in setup it detected and created db itself, how is that done, I want to build a setup which when may run on client machine, it may create a database in client amchine after detecting swl server, has anyone got idea how to do it?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Canan Kaya     Answered On: May 22

If you look in \FrameworkSDK\Samples\Setup you'll see an exe called configsetup ... it uses the sql files in the same dircetory to create  and install the database. Basically it uses dos to run  osql (main sqlserver program) ... a bit odd really that SQLServer is like 150% Windows orientated.
Though I think you could probably run .sql files from Enterprise Manager.

You could do it from a .bat file that would look similar to
@Echo Off

REM ***************************************************************************
REM ** File: CreateDatabase.cmd
REM ** Name: database  Setup
REM ** Desc: Database setup  batch file.
REM **
REM ** Date: 10/16/2001
REM **
REM **************************************************************************/

REM Use the following section to set the server  and sa password
REM of the SQL Server on which you want to create the database.
set SERVER=yourserver
set LOGIN=sa
set PWD=
set DBNAME=petshop3

@Echo.
@Echo *******************************************************************************
@Echo * Microsoft.NET PetShop Blueprint Application Database Setup *
@Echo * *
@Echo * *
@Echo * This script will create the .NET PetShop database and database objects. *
@Echo * If you wish to cancel, press [CTRL]-C and terminate the batch job. *
@Echo * *
@Echo *******************************************************************************
@Echo.
pause
@Echo.
@Echo.
@Echo *******************************************************************************
@Echo * Creating the Database... *
@Echo *******************************************************************************
@Echo.
osql -S %SERVER% -U %LOGIN% -P %PWD% -d master -i PetShop3_CreateDatabase.sql

@Echo.
@Echo.
@Echo *******************************************************************************
@Echo * Creating the Schema... *
@Echo *******************************************************************************
@Echo.
osql -S %SERVER% -U %LOGIN% -P %PWD% -d master -i PetShop3_Schema.sql

@Echo.
@Echo.
@Echo *******************************************************************************
@Echo * Inserting the Data... *
@Echo *******************************************************************************
@Echo.
osql -S %SERVER% -U %LOGIN% -P %PWD% -d %DBNAME% -i PetShop3_DataLoad.sql

@Echo.
@Echo *******************************************************************************
@Echo * *
@Echo * Script Complete *
@Echo * *
@Echo *******************************************************************************
@Echo.
pause

 
Didn't find what you were looking for? Find more on Setup Related Question Or get search suggestion and latest updates.




Tagged: