本文介绍了连接字符串重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。

i从aapcofig文件中恢复连接字符串有一些问题。

请帮助我。

im给出以下代码。



< in config =file =>



hello.
i have some problem with retriving connection string from aapcofig file.
please help me.
i m giving codes below.

<in config="" file="">

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <connectionStrings>

    <add name="con" connectionString="Server=.;Database=prince;Integrated Security=true"/>

  </connectionStrings>

</configuration>











(代码背后)




string connection = ConfigurationManager.ConnectionStrings [con]。ConnectionString;

但它无效。

i也用过






(Code Behind)


string connection = ConfigurationManager.ConnectionStrings["con"].ConnectionString;
but its not working.
i have also used

using System.Configuration;
using System.Data.SqlClient;





请帮忙我

问候

dibyaranjan



please help me
regards
dibyaranjan

推荐答案

<configuration>
  <appsettings>
    <add key="con" value="server=.;User Id=root;password=password;database=prince;" />
  </appsettings>
</configuration>





很乐意提供帮助。



happy to help.


<configuration>
<pre lang="HTML">
 <add name="mmisConnectionString" connectionString="server=localhost;User Id=root;password=password;database=mmis" providerName="MySql.Data.MySqlClient" />





< / connectionStrings>



< / configuration>



</connectionStrings>

</configuration>



这篇关于连接字符串重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 11:21