ADO.NET Flashcards

1
Q

What is ADO.NET?

A

ADO.NET is a set of classes (a framework) to interact with data
sources such as databases, XML files, text files or Excel files etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is ADO an acronym for?

A

ADO is the acronym for ActiveX Data Objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the two types of connection architectures?

A

Connected and disconnected.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is Connected Architecture?

A

The application remains connected with the database throughout the processing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Disconnected Architecture?

A

The application automatically connects/disconnects during processing. On the application side, it uses temporary data called a DataSet.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a connected environment?

A

A connected environment is one in which an application is constantly connected to a data source.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the advantages of connected environments?

A

Advantages:
- Data concurrency issues are easily controlled.
– At a time only one user can update the data in database.
- Data is always updated.

Disadvantages:
- A constant network connection is required which may lead to network traffic logging
- Scalability and performance issues in application.
– If more than one user connected to database, query processing may be slow

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a disconnected environment?

A

A disconnected environment is one in which a user is not necessarily connected with a database. Connection is required only at the time of retrieval or update and after that connection is closed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the advantages and disadvantages of a disconnected environment?

A

Advantages:
- Multiple applications can simultaneously interact with the database.
- Improve scalability and performance of applications.

Disadvantages:
- Data is not always updated.
- Data concurrency issues can occur when multiple users are updating the data to the data source.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the important classes in ADO.NET?

A

Connection, Command, DataReader, DateAdapter, DataSet

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the connection class?

A

Connection is an object that provides database connectivity and the entry point to a database.

When the connection of an object is instantiated, the constructor takes
a connection string that contains the information about the database
server, server type, database name, connection type, and database
user credentials.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the command class?

A

The Command class provides methods for storing and executing SQL statements and Stored Procedures.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the DataReader class?

A

The DataReader is used to retrieve data.

It is used in conjunction with the Command class to execute an SQL
SELECT statement and then access the returned rows.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the DataAdapter class?

A

This class is used in the Disconnected Model of ADO.NET.

The purpose of the DataAdapter is embedded in its name – it performs the activities necessary to get the data from the data source on the server into the database that’s held in the DataSet.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the six steps in the connected model?

A
  1. Create the SqlConnection object.
    * You’ll need the connection string to create it.
  2. Create the SqlCommand object.
    * You need the SQL query in string format.
    * And SqlConnection object created in the previous step.
  3. Open the connection.
  4. Execute the SqlCommand.
  5. Display the result.
  6. Close the connection.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a connection pool?

A

A connection pool is a cache of database connections maintained so that connections can be reused when future requests to the database are required.

17
Q

What does the ‘using’ statement do?

A

The using statement ensures that the SqlConnection is closed and disposed of properly, even if an exception occurs within the block.

18
Q

How do you use parameters in SQL?

A

Avoid String Concatenation: Using string concatenation for building SQL queries can lead to SQL injection attacks.
Use Parameters: Use the parameter features of ADO.NET to safely include parameters in SQL queries.

19
Q

What are three of the various commands executed by the SqlCommand class?

A

ExecuteReader, ExecuteScalar, ExecuteNonQuery

20
Q

What are the five steps used in the disconnected model?

A
  1. Create the SqlConnection object.
    * You’ll need the connection string to create it.
  2. Create the SqlDataAdapter object.
    * You need the SQL SELECT query in string format.
    * And SqlConnection object created in the previous step.
  3. Create DataSet object.
    * It’ll be used to store the local copy of the database.
  4. Fill the DataSet object using SqlDataAdapter object.
    * adapterObj.Fill(dataSetObj);
  5. Use the DataSet object to display the result.
21
Q

What does the SqlDataAdapter class do?

A

The SqlDataAdapter manages connections with the data source and gives us
the disconnected behaviour. The SqlDataAdapter opens a connection only when required and closes it as
soon as it has performed its task.

22
Q

What are the two useful methods the SqlAdapterClass has?

A

Fill:
* This method opens the connection, stores data from data source into DataSet
and then closes the connection.
Update:
* This method opens the connection, saves data from DataSet to the data
source and then closes the connection.