Click here to Skip to main content
16,012,352 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In our project we are using the DAL function structure like this
C#
public static class Read
    {
        private static SqlConnection DataConnection;
        private static SqlDataAdapter DataAdapter;
        private static SqlCommand DataCommand;
        private static DataTable objDataTable;

        static Read()
        {
            DataConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["testDB"].ConnectionString);
            DataCommand = new SqlCommand();
            objDataTable = new DataTable();
            DataAdapter = new SqlDataAdapter();
            DataCommand.Connection = DataConnection;
            DataAdapter.SelectCommand = DataCommand;
        }

        public static DataTable GetBranchesOfRestaurant(int RestaurantId, out string Error)
        {
            Error = string.Empty;
            objDataTable.Clear();
            objDataTable = new DataTable();
            DataCommand.CommandText = "GetBranchesOfRestaurant";
            DataCommand.Parameters.AddWithValue("@RestaurantId", RestaurantId);
            DataCommand.CommandType = CommandType.StoredProcedure;
            try
            {
                if (DataConnection.State != ConnectionState.Open)
                    DataConnection.Open();
                DataAdapter.Fill(objDataTable);
            }
            catch (Exception ex)
            {
                Error = ex.Message;
            }
            finally
            {
                DataCommand.Parameters.Clear();
                DataConnection.Close();
            }
            return objDataTable;
        }
}

But if multiple users using the website , different functions are overlapping and, front end function result and back end results are overlapping each other and the site is getting crashed.. what will be a standard structure for DAL function..Plz give me a solution
Posted
Updated 27-Jan-13 22:26pm
v3
Comments
dan!sh 28-Jan-13 3:25am    
What do you mean by overlapping? What error are you getting?
Member 9492907 28-Jan-13 3:40am    
In the front end page If we load a page, here we want to get the all the locations. at the same time any other user any other link, the front end data is replaced with back end data.The data reader is providing back end function result for front end..Like that it is happening in all the function if multiple actions done at the same time...what i want to do..
vinayraghavendra.hs 28-Jan-13 4:14am    
What you mean by the front end data is replaced with back end data?
Member 9492907 28-Jan-13 4:15am    
I mean one function result is replaced by another function result, if we access the both at the same time.
Shanu2rick 28-Jan-13 4:26am    
This is because you are allowing multiple users to access and modify the same data.

1 solution

Hi,
When using static members, functions or properties on the asp.net You must be careful. I think your problem is it. Don't use static members. Please edit your code and try again.

Good Days,
Ibrahim Uylas
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900