J
Joe Abou Jaoude
I m preparing to pass the 70-306 exam, so i downloaded Q & A
from multiple sites.
There's this question that really confuses me, coz i see that both
answers A and C are both correct.
Can anyone help me to pick the right answer and explain me why ?
thx.
Your development team creates an order entry application by using
Visual Studio .NET. The application stores and retrieves data in a
Microsoft SQL Server database. All database connections in the
application
are centralized in class variables within a class named
MyDataClass.
Each time your application needs to access data from the database,
it
creates an instance of MyDataClass by using the following code
segment:
Dim oData As New MyDataClass()
When the oData variable is no longer needed, it is set to Nothing
or goes out of scope. Initially, about 500 sales
representatives use the application. Later, your company hires 50 new
sales representatives who also use the application.
You discover that the database is running out of available connections
because of the increased usage. You must ensure
that database connections are released immediately when they are no
longer needed. You must also maintain an optimum
level of application performance.
What should you do?
A. Add the procedure Protected Overrides Finalize() to
MyDataClass.
Write code in the procedure to close all open database
connections.
B. Add the procedure Private Sub Finalize() to MyDataClass.
Write code in the procedure to close all open database
connections.
C. Implement the IDisposable interface within MyDataClass. Write
code in the Dispose
procedure of IDisposable to close all open database
connections. Call the
Dispose method of MyDataClass before any reference to
MyDataClass is set
to Nothing or goes of scope.
D. Find each location in your code where a reference to
MyDataClass is set
to nothing or goes out of scope. Add code after each instance
to manually
invoke the Visual Studio.NET garbage collector.
E. Add code to the Terminate event of MyDataClass to close all
open database connections.
F. Ensure that each reference to MyDataClass is set to Nothing
before it goes of scope.
Answer: A
from multiple sites.
There's this question that really confuses me, coz i see that both
answers A and C are both correct.
Can anyone help me to pick the right answer and explain me why ?
thx.
Your development team creates an order entry application by using
Visual Studio .NET. The application stores and retrieves data in a
Microsoft SQL Server database. All database connections in the
application
are centralized in class variables within a class named
MyDataClass.
Each time your application needs to access data from the database,
it
creates an instance of MyDataClass by using the following code
segment:
Dim oData As New MyDataClass()
When the oData variable is no longer needed, it is set to Nothing
or goes out of scope. Initially, about 500 sales
representatives use the application. Later, your company hires 50 new
sales representatives who also use the application.
You discover that the database is running out of available connections
because of the increased usage. You must ensure
that database connections are released immediately when they are no
longer needed. You must also maintain an optimum
level of application performance.
What should you do?
A. Add the procedure Protected Overrides Finalize() to
MyDataClass.
Write code in the procedure to close all open database
connections.
B. Add the procedure Private Sub Finalize() to MyDataClass.
Write code in the procedure to close all open database
connections.
C. Implement the IDisposable interface within MyDataClass. Write
code in the Dispose
procedure of IDisposable to close all open database
connections. Call the
Dispose method of MyDataClass before any reference to
MyDataClass is set
to Nothing or goes of scope.
D. Find each location in your code where a reference to
MyDataClass is set
to nothing or goes out of scope. Add code after each instance
to manually
invoke the Visual Studio.NET garbage collector.
E. Add code to the Terminate event of MyDataClass to close all
open database connections.
F. Ensure that each reference to MyDataClass is set to Nothing
before it goes of scope.
Answer: A