C # package MSDE In the installer

Source: Internet
Author: User
Add the automatic installation and merging module of Microsoft SQL Server 2003 Desktop Engine (MSDE) to the vs 2000 project. MSM:
1. Download The sp3a installation package of msde2000.
2. decompress the package to the local hard disk. The figure in the MSM folder is the msde2000 merging module.
3. add an installation project in your project, assuming mysetup, add project output according to the normal steps, select the output file (primary output) and content file (content files).
4. add the Merge Module (merge Moudle), select Browse, specify to your MSDE's MSM folder, and select all the files (repl) under MSM (excluding msm1033 and msm2052. MSM, repl_res.msm, dmo_res.msm, and DMO. (Optional.
5. Set the searchpath in the properties of the installation project to specify the path of your MSM (MSM, msm1033, and msm2052 ).
6. set other attributes of the installer. Then you can compile your installation project.
7. We need to modify the installation package so that it can automatically install an MSDE instance after the program is installed (assuming the Instance name is myserver ). We need a Ms tool orca.
8. Use Orca to open the installation package file mysetup. MSI
Installexecutesequence table
Getsqlstates. xxxxxx 103-> 421
Installinitialize 1800-> 1799
Removeexistingproducts 1825-> 1800
Installuisequence table
Getsqlstates. xxxxxx 103-> 421
Add a property table
Sqlinstancename: msdedh instance service name
Sqlsecuritymode: SQL Logon
Sqlsapwd: SA Password
Disablenetworkprotocols = 0: This is also required for network access.

Override Installer
The following method applies. If sqlinstancename is not added, use the machine name to access MSDE.
Public override void commit (idictionary savedstate)
{
Base. Commit (savedstate );
// Start the Windows Service
New system. serviceprocess. servicecontroller ("MSSQLServer"). Start ();
// Additional database
Sqlconnection connection = new sqlconnection ("Password = **; user id = sa; Data Source =" + systeminformation. computername );
Sqlcommand cmd = new sqlcommand ("sp_attach_db", connection );
Cmd. commandtype = commandtype. storedprocedure;
Sqlparameter loginname = cmd. Parameters. Add ("@ dbname", sqldbtype. nvarchar, 20 );
Loginname. value = "yourname ";
Sqlparameter nickname = cmd. Parameters. Add ("@ filename1", sqldbtype. nvarchar, 50 );
Nickname. value = path. getdirectoryname (assembly. getexecutingassembly (). Location) + "yourname. MDF ";
Sqlparameter Password = cmd. Parameters. Add ("@ filename2", sqldbtype. nvarchar, 50 );
Password. value = path. getdirectoryname (assembly. getexecutingassembly (). Location) + "yourname. LDF ";
Connection. open ();
Cmd. executenonquery ();
Connection. Close ();
}
I think attaching a database is the best solution.
If you run the installation package on a machine without an SQL environment, MSDE is automatically installed and your database is appended. After the machine is restarted, the instance of SQL Server is automatically started.

 

Related Article

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.