Aman Jen

Aman Jen

  • NA
  • 141
  • 40.6k

Declaring connection string in a class

Aug 27 2013 1:31 AM
Hi,
   Declaring connection string  in a class which is declared in web.config file


if do like this showing an error Non Invocable member



using System.Data.SqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
namespace CSharpTutorial
{
        public class MyFunctClass
              
    {
           string connstr = ConfigurationManager.ConnectionStrings ("myConnectionString").connectionString;  
          
   
    }
}

Plz help

Answers (27)