T
Tom
I try to do the following:
Generate a pooled connection in a web application. I use the following code:
In my Global.asax.cs
protected void Application_Start(object sender, EventArgs e)
{
//Creating a global pooled connection object
ConnectionStringSettings DBconn =
ConfigurationManager.ConnectionStrings["MyDatabase"];
SAConnection _conn = new SAConnection(DBconn.ConnectionString);
Application.Lock();
Application["DBConnection"] = (SAConnection)_conn;
Application.UnLock();
}
In the code behind of a web page I have:
protected void Page_Load(object sender, EventArgs e)
{
SAConnection _conn = (SAConnection)Application["DBConnection"];
string commandString = "Select * from MarkenAm";
SACommand command = new SACommand(commandString);
try
{
_conn.Open();
command.Connection = _conn;
SADataReader reader =
command.ExecuteReader(CommandBehavior.CloseConnection);
MarkeDL.DataSource = reader;
MarkeDL.DataBind();
}
finally
{
_conn.Close();
}
}
This works fine but I have to write all the code manually. Is there any
way to tell the designer about my connection pool stored in the
application scope of my web app?? I like to use the click an point
programming feature of the designer, but want all my web pages to use
the same centrally defined connection pool. Is this possible and if so how?
(I wrote tons of web apps in Java, but I am new to ASP.NET)
Thanks for your help
Thomas
Generate a pooled connection in a web application. I use the following code:
In my Global.asax.cs
protected void Application_Start(object sender, EventArgs e)
{
//Creating a global pooled connection object
ConnectionStringSettings DBconn =
ConfigurationManager.ConnectionStrings["MyDatabase"];
SAConnection _conn = new SAConnection(DBconn.ConnectionString);
Application.Lock();
Application["DBConnection"] = (SAConnection)_conn;
Application.UnLock();
}
In the code behind of a web page I have:
protected void Page_Load(object sender, EventArgs e)
{
SAConnection _conn = (SAConnection)Application["DBConnection"];
string commandString = "Select * from MarkenAm";
SACommand command = new SACommand(commandString);
try
{
_conn.Open();
command.Connection = _conn;
SADataReader reader =
command.ExecuteReader(CommandBehavior.CloseConnection);
MarkeDL.DataSource = reader;
MarkeDL.DataBind();
}
finally
{
_conn.Close();
}
}
This works fine but I have to write all the code manually. Is there any
way to tell the designer about my connection pool stored in the
application scope of my web app?? I like to use the click an point
programming feature of the designer, but want all my web pages to use
the same centrally defined connection pool. Is this possible and if so how?
(I wrote tons of web apps in Java, but I am new to ASP.NET)
Thanks for your help
Thomas