Hi,
As Manohar pointed out, you can add a class to your project and proceed.
Another way would be to create a wrapper class for the methods provided by
the framework. Make an assembly (a .dll file) and reference it. This is in
case you have a 3 tier architecture and needs to access the data access
methods a lot..
A sample can be like this...
Create a static class like DataBase and have a private static connection
string
private static string sConnectionString = The connection string
You can then have methods like this for filling up datatable / dataset. You
can also have for ExecuteNonQuery and any others you need.
public static DataTable ExecuteDataTable(SqlCommand command)
{
using (SqlDataAdapter da = new SqlDataAdapter(command))
{
command.Connection = GetConnection();
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
}
Just another approach...
HTH,
Need any help, do post a msg back..
Happy coding
"RedRed" wrote:
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