C#+vs2005 里的app.config里的数据库连接串如何调用
app.config中如下:<configuration><configSections></configSections><connectionStrings><add...
app.config中如下:
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="CallDetailsMakerV1_2.Properties.Settings.MMPJT002_DDSConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MMPJT002_DDS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
我要在程序中建立一个 NEW SQLCONNECTION( 连接字符)
这个连接字符用 app.config 中的连接.怎么写??
快郁闷死了..
它说Configuration.ConfigurationManager
中Configuration下面没有ConfigurationManager类.
它只有
System.Configuration.ConfigurationSettings.AppSettings[];
怎么办啊...郁闷.
我试过了.用System.Configuration.ConfigurationSettings.AppSettings[];
不行的取不到数值.
或者是我不知道.那有别的方法么?
请求高手啊. 展开
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="CallDetailsMakerV1_2.Properties.Settings.MMPJT002_DDSConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MMPJT002_DDS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
我要在程序中建立一个 NEW SQLCONNECTION( 连接字符)
这个连接字符用 app.config 中的连接.怎么写??
快郁闷死了..
它说Configuration.ConfigurationManager
中Configuration下面没有ConfigurationManager类.
它只有
System.Configuration.ConfigurationSettings.AppSettings[];
怎么办啊...郁闷.
我试过了.用System.Configuration.ConfigurationSettings.AppSettings[];
不行的取不到数值.
或者是我不知道.那有别的方法么?
请求高手啊. 展开
2个回答
展开全部
<add name="CallDetailsMakerV1_2.Properties.Settings.MMPJT002_DDSConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MMPJT002_DDS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />春指
换成
<扒晌配add key="conn"
value="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MMPJT002_DDS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
/>
然后那边接收用string str=System.Configuration.ConfigurationSettings.AppSettings["谨清conn"].ToString();
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MMPJT002_DDS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />春指
换成
<扒晌配add key="conn"
value="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MMPJT002_DDS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
/>
然后那边接收用string str=System.Configuration.ConfigurationSettings.AppSettings["谨清conn"].ToString();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询