c#读取APP.Config文件问题!!!急急!!
下面这段在C#里面怎么读取<?xmlversion="1.0"encoding="utf-8"?><configuration><configSections></con...
下面这段在C#里面怎么读取
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="WindowsFormsApplication1.Properties.Settings.dbConnectionString"
connectionString="Data Source=|DataDirectory|\db.sdf" providerName="Microsoft.SqlServerCe.Client.3.5" />
</connectionStrings>
</configuration> 展开
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="WindowsFormsApplication1.Properties.Settings.dbConnectionString"
connectionString="Data Source=|DataDirectory|\db.sdf" providerName="Microsoft.SqlServerCe.Client.3.5" />
</connectionStrings>
</configuration> 展开
4个回答
展开全部
string str = System.Configuration.ConfigurationManager.ConnectionString["连接的名字"].ToString();
SqlConnection cn = new SqlConnection(str);
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandText = sSql;
cmd.CommandType = CommandType.Text;
SqlConnection cn = new SqlConnection(str);
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandText = sSql;
cmd.CommandType = CommandType.Text;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用XmlDocument类型,读取当前目录下面的App.Config文件。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
private string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["WindowsFormsApplication1.Properties.Settings.dbConnectionString"].ConnectionString
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
System.Configuration.ConfigurationManager.ConnectionStrings["WindowsFormsApplication1.Properties.Settings.dbConnectionString"].ConnectionString;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询