scope of static property

  • Thread starter Thread starter Amit
  • Start date Start date
A

Amit

I'm supporting an asp dotnet application. There is a static property
in the code as below. Can anyone tell me in multiuser enviornment,
this propery will return a different dataset each time it is accessed
by different users?

public static DataSet GetRatings(string ratingString)
{
// Create a new dataset
DataSet dsReturn = new DataSet();

// Open a connection
SqlConnection _connection = new
SqlConnection(GlobalConstant.DBConnection);
_connection.Open();

// Create an adapter and populate the dataset
SqlDataAdapter sqlAdapter = new
SqlDataAdapter("spGetRatingDropdown", _connection);
sqlAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
sqlAdapter.SelectCommand.Parameters.Add("@sRatingCode",
ratingString);
sqlAdapter.Fill(dsReturn,"SearchResult");
sqlAdapter.Dispose();

_connection.Close();

return dsReturn;

}
 
Hi,

Yes, each caller will get a new instance of the dataset. However, if your
dataset property was a static member, then each caller would get the same
instance of the dataset.

Regards,
Luke Venediger
http://blogdotnet.blogspot.net
 
Thanks alot. Actually that was a function and not the property. I
wanted to post the a different code for the property instead I posted
code for the function.
anyways, your answer satisfies my query. thank you.
Amit
 
Back
Top