在安装程序包里放上你预先准备好的用来创建数据库的sql脚本,在安装程序里获得登陆SQL的用户名和密码后,调用该SQL脚本创建数据库。

解决方案 »

  1.   

    这段脚本写在哪里
    什么时候调用
    安装程序只会打包文件,怎么让它自动
    调用*.sql脚本执行。
    不是很明白
    拜托说清楚点
      

  2.   

    如  lese9(乐色.Net) 那样...1、在SQL Server 里生成某个数据库的SQL脚本.
    2、写一个Web界面的安装程序,让用户输入sql服务器的IP 地址,端口、用户名、密码、及数据库名
    3、根据这些信息创建一个链接字符串,根据这个字符串来生创建SqlConnection及Sqlcommand对象,然后用StreamReader读入SQL脚本,输给 Sqlcommand.commandText,最后执行 Sqlcommand.ExecuteNonQuery()  (这一步具体见http://expert.csdn.net/Expert/topic/2296/2296774.xml?temp=2.498806E-03 思归回的很好)
      

  3.   

    写成一个XML文件
    <?xml version="1.0" encoding="utf-8" ?> 
    <Setup>
    <VirtualDirectory>
    <Item Name="ProASPNet" Path="" Rooted="True"/>
    <Item Name="Simpleconfig" Path="02 - Introducing .NET\simpleconfig"/>
    <Item Name="GlobalasaxAdvanced" Path="12 - Web Applications and Globalasax\Advanced" />
    <Item Name="GlobalasaxComponent" Path="12 - Web Applications and Globalasax\Component" />
    <Item Name="GlobalasaxAsync" Path="12 - Web Applications and Globalasax\Globalasax\Async\Application" />
    <Item Name="GlobalasaxCustomData" Path="12 - Web Applications and Globalasax\Globalasax\EventExamples\CustomData" />
    <Item Name="GlobalasaxError" Path="12 - Web Applications and Globalasax\Globalasax\EventExamples\Error" />
    <Item Name="GlobalasaxFooter" Path="12 - Web Applications and Globalasax\Globalasax\EventExamples\Footer" />
    <Item Name="GlobalasaxInherits" Path="12 - Web Applications and Globalasax\Globalasax\Inherits" />
    <Item Name="GlobalasaxRequestCache" Path="12 - Web Applications and Globalasax\Globalasax\ResolveRequestCache" />
    <Item Name="GlobalasaxProcessModel" Path="12 - Web Applications and Globalasax\ProcessModel" />
    <Item Name="ConfigCompilation" Path="13 - Configuration and Deployment\Compilation\Remote" />
    <Item Name="ConfigGlobalization" Path="13 - Configuration and Deployment\Globalization" />
    <Item Name="ConfigHttpHandler" Path="13 - Configuration and Deployment\HttpHandler" />
    <Item Name="ConfigHttpModule" Path="13 - Configuration and Deployment\HttpModule" />
    <Item Name="ConfigImpersonate" Path="13 - Configuration and Deployment\Impersonate" />
    <Item Name="ConfigSectionHandler" Path="13 - Configuration and Deployment\SectionHandler" />
    <Item Name="ConfigSession" Path="13 - Configuration and Deployment\Session" />
    <Item Name="ConfigTracing" Path="13 - Configuration and Deployment\Tracing\TraceTool" />
    <Item Name="forms-based" Path="14 - Securing ASP.NET Applications\form-based" />
    <Item Name="custom-forms-based" Path="14 - Securing ASP.NET Applications\custom-form-based" />
    <Item Name="personalization" Path="14 - Securing ASP.NET Applications\personalization" />
    <Item Name="windows" Path="14 - Securing ASP.NET Applications\windows" />
    <Item Name="Collections" Path="15 - Working with Collections and Lists" />
    <Item Name="BusinessObjects" Path="17 - Building Business Objects" />
    <Item Name="ServerControls" Path="18 - Building ASP.NET Server Controls" />
    <Item Name="WebServices" Path="19 - Exposing Web Services" />
    <Item Name="WebServiceFormsAuth" Path="20 - Consuming Web Services\FormsAuthentication" />
    <Item Name="WebServiceFormsAuthentication" Path="20 - Consuming Web Services\FormsAuthentication\Consumer" />
    <Item Name="WebServiceBasicAuthentication" Path="20 - Consuming Web Services\BasicAuthentication\Consumer" />
    <Item Name="SessionState" Path="20 - Consuming Web Services\SessionState\Consumer" />
    <Item Name="TimeoutExample" Path="20 - Consuming Web Services\Timeout\Consumer" />
    <Item Name="SoapExtensions" Path="20 - Consuming Web Services\SoapException\Consumer" />
    <Item Name="SoapExtensions" Path="20 - Consuming Web Services\SoapExtensions" />
    <Item Name="ScreenScrape" Path="20 - Consuming Web Services\ScreenScrape" />
    <Item Name="SoapHeaderSimple" Path="20 - Consuming Web Services\SoapHeaderSimple" />
    <Item Name="SoapHeaderAuthentication" Path="20 - Consuming Web Services\SoapHeaderAuthentication" />
    <Item Name="Mobile" Path="21 - The Mobile Internet Toolkit" />
    <Item Name="Debugging" Path="22 - Debugging, Tracing, and Error Handling" />
    <Item Name="Interop" Path="23 - Migration and Interoperability" />
    <Item Name="IBuyAdventure" Path="24 - Case Study\IBuyAdventure" Rooted="True"/>
    </VirtualDirectory>
    <WritePermissions>
    <Item Path="08 to 11 - Data Management\data02" />
    <Item Path="08 to 11 - Data Management\data04" />
    <Item Path="08 to 11 - Data Management\data05" />
    <Item Path="16 - Working with Other Base Classes\IO\" />
    <Item Path="20 - Consuming Web Services" />
    </WritePermissions>
    <DataBase>
    <Item Name="WroxBooks" Script="WroxBooks.sql" DefaultData="WroxBooks.mdf" DefaultLog="WroxBooks.ldf" />
    <Item Name="IBuyAdventure" Script="IBuyAdventure.sql" DefaultData="IBuyAdventure.mdf" DefaultLog="IBuyAdventure.ldf" />
    <Item Name="UserList" Script="UserList.sql" DefaultData="UserList.mdf" DefaultLog="UserList.ldf" />
    </DataBase>
    </Setup>
    -------努力学习 不断实践 虚心讨教--------
      

  4.   

    如:lese9(乐色.Net) 
    winform下做过,不知道在webform下是不是一样~