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

Top 5 Contributors of the Month
david stephan
Gaurav Pal

Home >> Interview Question >> ADO.Net >> Post New Question Subscribe to Interview Questions

What is the Use of Connection Object ?

Posted By :Srikanth     Posted Date :April 22, 2011    Points :40   Category :ADO.Net 
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();

You can also find related Interview Question to What is the Use of Connection Object ?  below: 

What is the use of connection object?

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

What is a Null object?

It is an object of some class whose purpose is to indicate that a real object of that class does not exist. One common use for a null object is a return value from a member function that is supposed to return an object with some specified properties but cannot find such an object. (More...)

What is Object Oriented model?

This model is based on collection of objects. An object contains values stored in instance variables with in the object. An object also contains bodies of code that operate on the object. These bodies of code are called methods. Objects that contain same types of values and the same methods are grouped together into classes. (More...)

Where do you store connection string?

Database connection string can be stored in the web config file.
The connection string can be stored in the WEB.Config file under
element. (More...)

What does connection string consist of?

The connection string consists of the following parts:
In general:

Server: Whether local or remote.

Uid: User Id (sa-in sql server)

Password: The required password to be filled-in here

Database: The database name. (More...)

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...)

What is object Reference Tracing?

Object Reference Tracing is record sequential stack traces each time whenever object reference counter is incremented or decremented. These traces help to detect object reference errors, double-dereferencing, failure to reference. (More...)

How you will write a Connection String in web.Config fiel?

Ans) Then write below lines of code:

add name="sqlconnectionstring" connectionString="Data Source=INTHIYAAZ;Initial Catalog=DB;User ID=sa;Password=sa" />

To perform asynchronous data access, what must be added to the connection string?

Select Correct Answer.

1. BeginExecute=true
2. MultiThreaded=true
3. MultipleActiveResultSets=true
4. Asynchronous=true

Correct Answer:
4. Asynchronous=true (More...)

Is it possible to update a connection string stored in the Web.config file programatically? If Yes, then how?


Create a Configuration object. Then, update the connection string using the ConnectionStrings collection. Finally, call Configuration.Save. (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