Hi,
"Macca" <Ma***@discussi ons.microsoft.c om> wrote in message
news:B9******** *************** ***********@mic rosoft.com...
Hi Ignacio,
Wouldn't I have to lock the methods in the database access class while in
use to stop them being called from elsewhere in the business logic?
No, unless the DB class is using shared resources, which you should not.
Here is an example, this class deal with the DB comm, it does receive a
SqlCommand (which is built by the BO ).
As you can see none method use any shared resources, and a connection is
created and closed inside the method.
public class DataProvider
{
static string connString;
public static string ConnString
{
get{ return connString;}
set
{
connString = value;
}
}
static public object ExecuteScalar(S qlCommand command)
{
object returnvalue = null;
if ( connString == "")
throw new Exception("No connection string defined");
SqlConnection conn = new SqlConnection( connString);
try
{
conn.Open();
command.Connect ion = conn;
returnvalue = command.Execute Scalar();
}
catch( Exception e)
{
throw new Exception("Erro r ocurred in ExecuteScalar: commandtext: " +
command.Command Text, e);
}
finally
{
conn.Close();
}
return returnvalue;
}
static public SqlDataReader ExecuteReader(S qlCommand command)
{}