public partial class Prod : System.Web.UI.Page
{

}

Here i have another class file called clsdbconnection which has connection string function called getconnectiondb().

To use that getconnectiondb() function i need to use the class in the present class prod.

How to use the class, I tried all these ways but it gives error

public partial class Prod : clsdbconnection : System.Web.UI.Page
{

}

public partial class Prod , clsdbconnection : System.Web.UI.Page
{

}

public partial class Prod : clsdbconnection , System.Web.UI.Page
{

}

Use code tags

You can't inherit classes in this manner. Create an instance of class clsdbconnection.

Hi,
I think you want to implement your application as a three tier
architecture.
i.e., seperating presentation, business logic and data access
Well i can suggest you some other way.

first you have created a class called Prod

public partial class Prod : System.Web.UI.Page
{

}

Now create a class file clsdbconnection .
when you create class file you will be prompted to save the file in App_Code folder.click ok and that's it.youc can now define the function
getconnectiondb() in the class file.The function can now be accessed
from the class Prod.

In the Page_Load of Prod class create an instance of clsdbconnection

clsdbconnection db=new clsdbconnection ();

call the function and store the value returned by the function in
appropriate variable.


All The Best

Here i have another class file called clsdbconnection which has connection string function called getconnectiondb().

To use that getconnectiondb() function i need to use the class in the present class prod.

How to use the class, I tried all these ways but it gives error

To use the methods/functions of class, you don't need to inherit that class in your present class.

You need to create an instance of the class and call the appropriate method.

For example, to call the getconnectiondb of clsdbconnection in Prod class

clsdbconnection  dbConn = new clsdbconnection ();
dbConn.getconnectiondb ();

If getconnectiondb returns a value, then store it in a appropriate object variable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.