开发者

SQL server connectivity using ConfigurationManager.ConnectionString

I am not able to use

String connectionString = ConfigurationManager.ConnectionStrings["DevBackup"].ConnectionString;

I am getting error 'The nam开发者_JS百科e 'ConfigurationManager' does not exist in the current context'

I have used namespaces

using System.Data.SqlClient;
using System.Data.Sql;

what should be done..?? Am I missing something..??


You need to add a reference to the System.Configuration assembly to your project, and then a using System.Configuration; statement to your app.


Do you also have System.Configuration in your namespaces?


For ASP.NET, System.Web.Configuration is the correct namespace to use:

using System.Web.Configuration;
String connectionString = WebConfigurationManager.ConnectionStrings["DevBackup"].ConnectionString;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜