scampercat

scampercat

  • NA
  • 189
  • 0

asp.net obtaining data from sql server

Jul 8 2012 12:22 PM
I am asking this question since I would like to know what is the best method of coding in a C # 2010 web form page that I just wrote. I read somewhere that everytime you need a datacontext object, you should create it. There was no reference also to removing the datacontext object.

Thus on the current web form page that I am using that connects to a sql server 2008 r2 database, I am doing the following:

1. I never remove the AttDataContext from memory.

2. On the same web page, I am referring to the same linq to sql *.dbml file. However depending upon what I user clicks on, I have the following 3 datacontext objects:

a. AttDataContext,

b. Att2DataContext,

c. Att3DataContext.

Can you tell me if the above if a good idea or not? If not, can you tell me how I should use the same data context object on the same web form page?