This is a strange problem to describe so you will have to bear with me! I
have developed a web application using c#.net that utilises server side ASPX
pages that connect to a SQL2000 database. I have been load testing my
application with the Microsoft Application Test Center that comes with Visual
Studio 2003, with simulated loads of 10 - 400 users.
When I run a test against my web application for upwards of 10 concurrent
users I start to get strange results from the database for what should be
routine queries. I execute a simple query looking for a row in a table which
I know is there (100% certain!) and the query returns the results to a
dataset. I then get the first datatable from the dataset and check that the
dataset.rows.count variable is greater then 0. Which it always is! I then
proceed to look for a column that exists in the table which I specifically
selected and an exception is thrown telling me the column doesnt exist in the
datatable. This is actually impossible the data is DEFINATLEY there!
I can log into SQL Query analyser as the same SQL logon that the ASPX page
uses to connect and run the same query and it returns the expected results
without error or anaomoly.
Once an error of this type has occured, I can replicated it upto 10 minutes
after it first has happened. During this 10 minute period I can switch the
SQL logon the ASPX uses and it runs fine. As soon as I switch it back to the
user on which the error occured it demonstrates the same problem again. After
10 minutes the problem disappears and wont happen again until I apply a heavy
load to the server.
As an important note, I have now managed to replicate an identical problem
with just 2 users trying to concurrently login.
Here is the snippet of code iam using to query the database:
public static DataSet execute_DataTable(String SQL_Command_String)
{
String connectionString;
connectionString =
getConnectionString(@"..\xml_Settings\DB_Connect.xml");
makeConnection(connectionString);
DataSet dsResults = new DataSet();
try
{
SqlDataAdapter dbAdapter = new
SqlDataAdapter(SQL_Command_String, dbConn);
dbAdapter.Fill(dsResults, "Results");
}
catch (Exception exp)
{
throw new Exception(exp.Message + " " + exp.StackTrace, exp);
}
finally
{
dbConn.Close();
}
return dsResults;
}
This function is located in a static class in a class library that compiles
to a DLL that is then referenced in my web project. Every time an ASPX page
requires to query the database this method is called.
When I load test my application a typical session will involve 2000 queries
in a very short period of time. This is because I use a recursive c# function
for generating a tree that executes alot of SQL queries.
Iam really out of ideas here guys , does any one have any ideas? All I can
think of is disposing of the dataset when iam done?
Thanks in advance!
Mike