如何在asp。net程序发布后,通过exe或bat、ini的形式动态配置app.cnofig中的连接字符串配置信息。
app。config在da层的da.dll文件中,或都通过页面设置也可以,需要完整实例,谢谢

解决方案 »

  1.   

    app.config文件
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
        </configSections>
        <connectionStrings>
            <add name="DataAccess.Properties.Settings.SRMSConnectionString"
                connectionString="Data Source=(local);Initial Catalog=ss;User ID=sa;pwd=bhu_keyan8.22;"
                providerName="System.Data.SqlClient" />
        </connectionStrings>
    </configuration>通过程序修改数据库名,密码等,因为此文件在da层,所以这个文件在da.dll中
      

  2.   

    可以另外添加一个自己的xml配置文件啊
    或者直接读写呗,都是xml文件嘛
      

  3.   

    发布后就只能操作dll了,得用反射吗?
      

  4.   

    或者说,把web。config中的连接字符串写到app。config中,
      

  5.   

    没明白?
    setting.settings设置的连接字符串,只能在源码里更改,要想控制setting。settings就得操作app。config
      

  6.   

    把config放到ui层,da是数据访问层用什么config
      

  7.   

    那dal层用强类型 的dataset添加adapter时用什么做连接字符串
    不是在setting.settings中写吗,能直接连到ui的web.config吗
      

  8.   

    在<appseting></appseting>中加入
    <add
        key="DBConnstring"
           value="server=(loacl);database=数据名;User id=sa;Pwd=密码"
    />
    调用时直接用“ConfigurationManger.AppSetings("DBConnstring”)
      

  9.   

    Let me try and explain my problem more clearly. I want my DataSet to use the Connection String named "SiteSqlServer" in my web.config.I am able to get this working at runtime with the following connection info in my DataSet's xsd file:        <Connections>
              <Connection AppSettingsObjectName="Web.config" AppSettingsPropertyName="SiteSqlServer" ConnectionStringObject="" IsAppSettingsProperty="True" Modifier="Assembly" Name="SiteSqlServer (Web.config)" ParameterPrefix="@" PropertyReference="AppConfig.System.Configuration.ConfigurationManager.0.ConnectionStrings.SiteSqlServer.ConnectionString" Provider="System.Data.SqlClient">
              </Connection>
            </Connections>Unfortunately this same code does not work at design time. At design time I need to use the following:        <Connections>
              <Connection AppSettingsObjectName="Settings" AppSettingsPropertyName="CommunityServerConnectionString" ConnectionStringObject="" IsAppSettingsProperty="True" Modifier="Assembly" Name="CommunityServerConnectionString (Settings)" ParameterPrefix="@" PropertyReference="ApplicationSettings.RunHub.Properties.Settings.GlobalReference.Default.CommunityServerConnectionString" Provider="System.Data.SqlClient">
              </Connection>
            </Connections>The above code works at both runtime and design time but leaves me having to update the connection string in both the DLL's app.config in which the DataSet resides and in the web.config of the WAP which references the DLL.Currently, when I am finished with dev and ready for prod I plan on returning to the method which only works at runtime to avoid multiple connection strings, but as you can see, it is cumbersome to keep switching between these methods and ideally I would like something that works correctly during both runtime and design time.It may be helpful to note that both the Web Application Project(WAP) and the Class Library(DLL) are part of the same solution.
    If you need any additional info please let me know. I really appreciate your help.