Automatic installation of MSDE using methods

Source: Internet
Author: User
Tags exit modify parent directory visual studio backup
Automatically install one, make an automatically installed SQL

has been completed, the program is placed in:

\ \ \ \ \ \ \ \ \ \msde

Description: The purpose of automatic installation is to not appear when the MSDE installer is executed, and to install automatically according to the configured steps;

How to make an automatic profile Unattend.iss:

Start the installation with SQL Server Setup, select Advanced Options, and then select Unattended, and then the selections and configurations for the installation are saved to C:\windows\SETUP. ISS file, the file is the Unattend.iss mentioned above.

After making an unattended file, executing the Setup.bat file in it automatically installs SQL. SQL can be automatically installed as long as there is a way to automate the contents of the file in our application's installation disk.



Ii. Modification of SETUP1.exe

For VB Project packaging, installation program in addition to the normal implementation of the application of the installation function, in addition to the automatic implementation of our production unattended SQL Installer, you must modify the VB packaging tools. The modification method is as follows:

A, open the Setup1 project under the C:\Program Files\Microsoft Visual Studio\vb98\wizards\pdwizard\setup1 Directory

B, the following statement is found in the Exitsetup procedure in the Basesetup1 module:

Case Intexitcod

.........

Case Else



C, increase the number of SQL automatically installed statements before case Else

D, compiled into EXE files

E, copy the compiled EXE file to the parent directory:

C:\Program Files\Microsoft Visual Studio\vb98\wizards\pdwizard

Currently compiled programs are placed in the

\\CHANCE-SERVER\ project \ Installation disk making \setup1



Third, the production of database documents

Because this MSDE is a basic SQL SEREVER7, you must have SQL SERVER7 to back up the database used by the application to a filename (for example, Dbback).







Four, packing

A, the project printing package, the SQL of the Automatic installation program (Msde86.exe, Unattend.iss) to the package, when packaging the 2 program to specify the decompression path:

$ (WinSysPath)

B, the production of the database backup file (Dbback) also hit the package, when packaging the file to specify the decompression path:

$ (AppPath)

C, the application of the configuration file, the use of instructions, and so on at the same time to the package, packaging, specify the file decompression path is:

$ (AppPath)





V. Installation

When the application is installed, after performing the standard installation steps, ask:

Do you want to install the database?

Select Yes to install SQL automatically (do not install for machines that already have SQL Server).

Note: Sometimes the Setup program is installed under Windows2000, after copying 8 initialization programs, prompt "program obsolete" requires reboot and install. However, it is still the same problem after reboot and cannot be installed. At this point, modify the Setup.lst file in the installation package in:

File3= @VB6CHS. dll,$ (WinSysPath),, $ (Shared), 10/2/00

Before adding REM, this reinstall will only copy the top 2 files and the installer can execute smoothly.





Six, run the program

After the program is installed, the database required by the application is not mounted in SQL SERVER. The ability to automatically add a database to SQL Server should be added to the VB application we write.

Implementation method: Every time you start the application, determine if there is a database in the SQL Server database that we want, and if not, execute the following action:

1, copy the backup file to the master database corresponding directory;

2. Use the Data Recovery command to restore the backup files in the master directory to the specified database name.

List of programs see next page:







=============== This function must be used before connecting to the database ================



=============== must be applied in engineering sqldmo================



Public Function Scopymdf (ssvrname As String, Sdbname as String, SUID as String, spwd as String, Smdfname as String) as Str Ing

Parameter description: Ssvrname: Server name

Sdbname: Database name

SUID: User Name

SPWD: Password,

Smdfname: Database backup file name



Dim Fso as Scripting.FileSystemObject

Dim strmessage as String

Dim DB as Variant

Dim Fdatabaseflag as Boolean

Dim X, Osvr

On Error Resume Next

Scopymdf = ""

Fdatabaseflag = False

Set Fso = CreateObject ("Scripting.FileSystemObject")

Set Osvr = CreateObject ("SQLDMO. SQL Server ")

Osvr.connect Ssvrname, SUID, spwd

Osvr.start True, Ssvrname, SUID, spwd

X = Osvr.Databases.Count ' If it fails, DMO needs to be initialized

' By looping through all database names on the local MSDE server,

' Check if demodatabase exists on this server.

For all db in osvr.databases

If db. Name = Sdbname Then ' The database exists

Fdatabaseflag = True

Exit For ' Quit loop

End If

Next

If not Fdatabaseflag Then ' does not exist a database named Demodatabase

Dim Orestore as New SQLDMO. Restore

Orestore.action = Sqldmorestore_database

Orestore.database = Sdbname

Fso.copyfile App.Path & "\" & Smdfname, _

Osvr.databases ("Master"). Primaryfilepath & Smdfname, True



Orestore.files = osvr.databases ("Master"). Primaryfilepath & Smdfname



Orestore.replacedatabase = True

' Judge if there is a ' C:\mssql7\Data\ ' directory, no, you have to build this directory first

Orestore.sqlrestore Osvr



Else

Scopymdf = smdfname & "Quit MSDE Server"

End If

Exitcopymdf:

Osvr.disconnect

Set Osvr = Nothing

Exit Function

Scopymdftrap:

If Err. Number = -2147216399 Then ' DMO needs to be initialized

Resume Next

Else

Scopymdf = Err. Description

End If

Resume Exitcopymdf

Exit Function

End Function





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.