尝试使用c#连接时配置系统无法初始化

时间:2013-06-19 10:19:28

标签: c#-4.0 app-config sqlconnection

我正在尝试从我的应用程序连接到SQL服务器并且我收到以下错误:“配置系统无法初始化”。

这是我的App.config文件:

    <?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <ConnectionString>
    <add name="ConStr" ConnectionString="Data Source=10.0.0.111;Initial Catalog=InfoDesk;User ID=sa" />
  </ConnectionString>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
</configuration>

这是来自app:

SqlConnection sqc = new SqlConnection(ConfigurationManager.ConnectionStrings["ConStr"].ConnectionString);

无尽的荣耀,以获得一个好的答案

谢谢, 埃雷兹

1 个答案:

答案 0 :(得分:1)

我看过this页面。有一个sql-server 2005的连接字符串示例。

我不确定,但我认为你必须在你的连接字符串中指定databaseprovider。

更新

在connectionstrings.com上为SQL-Server 2008找到了一些东西:

Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;
User ID=myUsername;Password=myPassword;

看看this。也许你的IP有问题