分享
 
 
 

Using a Custom Action to Create a Database During Installation

王朝c#·作者佚名  2006-12-17
窄屏简体版  字體: |||超大  

The following walkthrough demonstrates the use of a custom action and the CustomActionData property to create a database and database table during installation.

On the File menu, point to New, and then choose Project. In the New Project dialog box, select Visual Basic Projects in the Project Type pane, and then choose Class Library in the Templates pane. In the Name box, type DBCustomAction. Click OK to close the dialog box. On the Project menu, choose Add New Item. In the Add New Item dialog box, choose Installer Class. In the Name box, type DBCustomAction. Click OK to close the dialog box.

In Server Explorer, select Data Connections. Right-click and choose Add Connection. In the Data Link Properties dialog box, do the following: Enter the server name. Select Use Windows NT Integrated Security. In the database box, type master. Click OK to close the dialog box. Drag the new connection and drop it on the DBCustomAction.vb designer to create a sqlConnection1 object.

In Solution Explorer, select the DBCustomAction project. On the Project menu, choose Add New Item. In the Add New Item dialog box, choose Text File. In the Name box, type sql.txt (must be in lower case). Click OK to close the dialog box. Add the following to the sql.txt file:

In Solution Explorer, select sql.txt. In the Properties window, set the BuildAction property to Embedded Resource.

In Solution Explorer, select DBCustomAction.vb. On the View menu, choose Code. Add the following Imports statement at the top of the module:

Add the following code to the class:

On the Build menu, choose Build DBCustomAction.

On the File menu, choose Add Project, New Project. In the Add Project dialog box, select Setup and Deployment Projects in the Project Type pane, and then choose Setup Project in the Templates pane. In the Name box, type DBCustomAction Installer. Click OK to close the dialog box. In the Properties window, select the ProductName property and type DB Installer. In the File System Editor, select the Application Folder. On the Action menu, choose Add, Project Output. In the Add Project Output Group dialog box, select the primary output for the DBCustomAction project. Click OK to close the dialog box.

Select the DBCustomAction Installer project in Solution Explorer. On the View menu, point to Editor, and choose User Interface. In the User Interface Editor, select the Start node under Install. On the Action menu, choose Add Dialog. In the Add Dialog dialog box, select the Textboxes (A) dialog, then click OK to close the dialog box. On the Action menu, choose Move Up. Repeat until the Textboxes (A) dialog is above the Installation Folder node. In the Properties window, select the BannerText property and type Specify Database Name. Select the BodyText property and type This dialog allows you to specify the name of the database to be created on the database server. Select the Edit1Label property and type Name of DB:. Select the Edit1Property property and type CUSTOMTEXTA1. Select the Edit2Visible, Edit3Visible, and Edit4Visible properties and set them to false.

Select the DBCustomAction Installer project in Solution Explorer. On the View menu, point to Editor, and choose Custom Actions. In the Custom Actions Editor, select the Install node. On the Action menu, choose Add Custom Action. In the Select item in project dialog box, double-click the Application Folder. Select the Primary output from DBCustomAction(Active) item, then click OK to close the dialog box. In the Properties window, select the CustomActionData property and type /dbname=[CUSTOMTEXTA1]. On the Build menu, choose Build DBCustomActionInstaller.

Select the DBCustomAction Installer project in Solution Explorer. On the Project menu, choose Install. This will run the installer on your development computer.

In Windows Explorer, navigate to your project directory and find the built installer. The default path will be \documents and settings\yourloginname\DBCustomAction Installer\project configuration\DBCustomAction Installer.msi. The default project configuration is Debug. Copy the DBCustomAction Installer.msi file and all other files and subdirectories in the directory to another computer. On the target computer, double-click the Setup.exe file to run the installer.

In the Windows Control Panel, double-click Add/Remove Programs. In the Add/Remove Programs dialog box, select DBCustomAction Installer and click Remove, then click OK to close the dialog box. Project menu, choose Uninstall.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有