0
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
{

}

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.

4
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by Ramesh S
0

Use code tags

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

0

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

0

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.

Edited by Ramesh S: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.