-4

how do I read connection string from class in asp.net c# ? also how can I read connection in my project as public in all pages? is that possible?

thanx

1 Answers1

0

if you want to use class for accessing then you can access by a public variable or by a function like

    class abc
    {
        public static string connection_string = "your connection string";
    }
    class xyz
    {
        public string connection_string()
        {
            return "your connection string";
        }
    }
    class webpage // call here at any page
    {
        // by using variable
        string con_string = abc.connection_string;

        //by using function
        xyz obj_ = new xyz();
        string con_string1 = obj_.connection_string();
    }
Sukhvindra Singh
  • 200
  • 2
  • 14