.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Interview Question >> C# >> Post New Question Subscribe to Interview Questions

What does Dispose method do with the connection object?

Posted By :Ghanashyam Nayak     Posted Date :September 23, 2010    Points :10   Category :C# 
Deletes it from the memory.

You can also find related Interview Question to What does Dispose method do with the connection object?  below: 

How can I look up a parent class method or property of any System-level object?

Use the Class View window, accessed from the standard toolbar by clicking View | Class View. (More...)

Which method is used to serialize an object into an XML document from Xmlserializer class?

The "Serialize" method is the first step of serialize process and used to create an XML document (More...)

What is the Use of Connection Object ?

In order to interact with any database we need a Connection . This connection enables us to know the Server Name, User-Id,Password,Database Name. These are the main requirements to connect to a Database.

So in our Connection string we provide all those above mentioned properties as parameters.

Different Connection objects : SqlConnection, OleDbConnection, OdbcConnection

. OleDbConnection object is used with an OLE-Db Provider

OleDbConnection cnn ;

connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;

Data Source=DatabaseName;";

cnn = new OleDbConnection(connetionString);

. SqlConnection object used the Tabular Data Services (TDS) With MS Sql Server.

SqlConnection con;

con = new SqlConnection("server=SERVER NAME;user id=ID;password=PASSWORD;database=DB NAME");

SqlCommand cmd;

cmd = new SqlCommand("DB Query Here",con);

. Using the OdbcConnection , we will create an OdbcCommand. From that command we can issue a Query and create an OdbcDataReader.

OdbcConnection DbConnection = new OdbcConnection("Connection String");

OdbcCommand DbCommand = DbConnection.CreateCommand();

DbCommand.CommandText = "Db Query Here";

OdbcDataReader DbReader = DbCommand.ExecuteReader();

When should you not dispose SPWeb & SPSite object?

You should never dispose SPContext.Current.Web/Site &normally not dispose SPWeb if IsRootWeb is true. (More...)

What is the use of connection object?

It is used to create conection with the Database. (More...)

What is Method overloading?

Method overloading occurs when a class contains two methods with the same name, but different signatures. (More...)

What is Method Overriding? How to override a function in C#?

Use the override modifier to modify a method, a property, an indexer, or an event. An override method provides a new implementation of a member inherited from a base class. The method overridden by an override declaration is known as the overridden base method. The overridden base method must have the same signature as the override method.
You cannot override a non-virtual or static method. The overridden base method must be virtual, abstract, or override. (More...)

Can we call a base class method without creating instance?

Its possible If its a static method.

Its possible by inheriting from that class also.

Its possible from derived classes using base keyword. (More...)

What is the difference between Finalize and Dispose (Garbage collection)

Class instances often encapsulate control over resources that are not managed by the runtime, such as window handles (HWND), database connections, and so on. Therefore, you should provide both an explicit and an implicit way to free those resources. Provide implicit control by implementing the protected Finalize Method on an object (destructor syntax in C# and the Managed Extensions for C++). The garbage collector calls this method at some point after there are no longer any valid references to the object.
In some cases, you might want to provide programmers using an object with the ability to explicitly release these external resources before the garbage collector frees the object. If an external resource is scarce or expensive, better performance can be achieved if the programmer explicitly releases resources when they are no longer being used. To provide explicit control, implement the Dispose method provided by the IDisposable Interface. The consumer of the object should call this method when it is done using the object. Dispose can be called even if other references to the object are alive.

Note that even when you provide explicit control by way of Dispose, you should provide implicit cleanup using the Finalize method. Finalize provides a backup to prevent resources from permanently leaking if the programmer fails to call Dispose. (More...)

What is Method used to bind the data into gridview ?

DataBind() Method used to bind the data into gridview (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend