首页 新闻 会员 周边 捐助

C#读取Xml配置文件。配置系统未能初始化

0
悬赏园豆:10 [已关闭问题] 关闭于 2013-12-16 17:16
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <ConnectionStrings>
    <add key="sleepTime" value="60000"/>
    <add name="Sqlconn" value="Data Source=NICHOLAS_D-PC;User ID=sa;Password=sa;Database=Text" />
    <add name="port" value="5"/>
  </ConnectionStrings>
  <appSettings>
    </appSettings>
</configuration>

 

 

string con = ConfigurationManager.ConnectionStrings["Sqlconn"].ConnectionString;
            SqlConnection conn = new SqlConnection(con);
            conn.Open();
            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.StoredProcedure;        //设置cmd的类型为存储过程
            cmd.CommandText = "EXEC usp_CallSceneStep";
            cmd.Connection = conn;

            SqlParameter pCustomerID = new SqlParameter();
            pCustomerID.ParameterName = "@CustomerID";
            pCustomerID.SqlDbType = SqlDbType.NChar;
            pCustomerID.Value = "ALFKI";

            cmd.Parameters.Add(pCustomerID);
问题补充:

解决了

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
      <add key="sleepTime" value="60000"/>
      <add key="Sqlconn" value="Data Source=ADMIN-PC;User ID=sa;Password=sa;Database=Text" />
      <add key="port" value="5"/>
    </appSettings>
</configuration>
董毛毛的主页 董毛毛 | 初学一级 | 园豆:122
提问于:2013-12-16 10:09
< >
分享
所有回答(2)
0

系统的后缀名有没有显示出来?是不是错误的修改了文件名?看文件是web.config,但其实是web.config.config

水晶途途 | 园豆:1443 (小虾三级) | 2013-12-16 10:29
0
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
      <add key="sleepTime" value="60000"/>
      <add key="Sqlconn" value="Data Source=ADMIN-PC;User ID=sa;Password=sa;Database=Text" />
      <add key="port" value="5"/>
    </appSettings>
</configuration>
董毛毛 | 园豆:122 (初学一级) | 2013-12-16 17:15
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册