I think you have answered this yourself -- add a class to your project,
which connects to the database, and perhaps returns a connection object that
all pages can re-use.
// Define a class
public class MyConn
{
// This is the internal member to hold connection
SqlConnection _conn = null;
// Create a connection in the constructor
public MyConn()
{
// Create a connection in this constructor
}
// This is the public property
public SqlConnection Connection
{
get
{
return _conn;
}
}
}
Hope that helps.
--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"RedRed" <> wrote in message
news:4e0201c52249$8997a160$...
> Hi all,
>
> Hi to connect to database if I want to write the code in
> the class instead in the html (.aspx). What I want to do
> is to create a reusable class which allow the other page
> to connect using one class.
>
> Thanks all