error while adding connectionstring dynamically
-
the error is coming while i am using the following code. This is for add a connection string to datasource dynamically code: string cnStr; cnStr = ConfigurationSettings.ConnectionStrings["MyNWind"].ConnectionString; SqlConnection cnObj = new SqlConnection(cnStr); error: 'System.Configuration.ConfigurationSettings' does not contain a definition for 'ConnectionStrings' itsvery urgent. TIA
-
the error is coming while i am using the following code. This is for add a connection string to datasource dynamically code: string cnStr; cnStr = ConfigurationSettings.ConnectionStrings["MyNWind"].ConnectionString; SqlConnection cnObj = new SqlConnection(cnStr); error: 'System.Configuration.ConfigurationSettings' does not contain a definition for 'ConnectionStrings' itsvery urgent. TIA
Hi, Did you add a key like this inside your web.config file I think you should add like this. <connectionStrings> <add name="MyNWind" connectionString="My Connection String" /> </connectionStrings>
To succeed, we must first believe that we can. Sherin Iranimose
-
Hi, Did you add a key like this inside your web.config file I think you should add like this. <connectionStrings> <add name="MyNWind" connectionString="My Connection String" /> </connectionStrings>
To succeed, we must first believe that we can. Sherin Iranimose
yes i did that. but still its giving error
-
Hi, Did you add a key like this inside your web.config file I think you should add like this. <connectionStrings> <add name="MyNWind" connectionString="My Connection String" /> </connectionStrings>
To succeed, we must first believe that we can. Sherin Iranimose
here is the code in home.aspx: SqlDataSource ds = new SqlDataSource(); ds.ConnectionString = ConfigurationSettings.connectionStrings["ConnectionString2"].connectionString; ds.SelectCommand = "SELECT DEPTNO, DNAME FROM DEPT1 where deptno=@deptno"; here is the code in web.config: i alreadymentioned my error that what i am getting. try to help me asap. TIA
-
the error is coming while i am using the following code. This is for add a connection string to datasource dynamically code: string cnStr; cnStr = ConfigurationSettings.ConnectionStrings["MyNWind"].ConnectionString; SqlConnection cnObj = new SqlConnection(cnStr); error: 'System.Configuration.ConfigurationSettings' does not contain a definition for 'ConnectionStrings' itsvery urgent. TIA
Shouldn't it be: ConfigurationManager.ConnectionStrings["your_con_string"].ToString() Assuming this is for 2.0 and you've added the proper imports/using statement. e.g. (C#) using System.Configuration; (VB) Imports System.Configuration Hope this helps :->