WorksheetsCP3 FINALS
Total questions: 112
Worksheet time: 56mins
Represent a source that provides a sequence of bytes, such as a file, an input/output (I/O) device, an communication pipe, or a TCP/IP socket.
Streams
ADO.NET
File Pointer
Seek
It is a class that is used to create a byte-oriented stream attached to a file.
Streams
ADO.NET
File Pointer
FileStream
It refers to a printer, remote server location, or a printer where the data is written.
Output Streams
Input Streams
Data Buffer
Network Socket
It refers to a file or any source where the data can be read and assigned to the memory variables
in the program.
Output Streams
Input Streams
Data Buffer
Network Socket
In C#, which namespace contains classes specifically designed for working with files, including reading and writing their contents?
System.Text
System.Data
System.IO
System.Collections
The code to be used for creating a FileStream object is?
FileStream(string filename,FileMode mode)
FileStream(string path, FileAccess access)
FileStream(string path, FileMode mode, FileAccess access)
FileStream(string filename, FileShare share)
It creates a new output file, which will be overwritten if a file already exists.
FileMode.Create
FileMode.CreateNew
FileMode.Open
FileMode.OpenOrCreate
It creates a new output file that is not existing.
FileMode.Create
FileMode.CreateNew
FileMode.Open
FileMode.OpenOrCreate
It opens an existing file.
FileMode.Truncate
FileMode.CreateNew
FileMode.Open
FileMode.OpenOrCreate
It opens an existing. If not, it creates a new one.
FileMode.Truncate
FileMode.CreateNew
FileMode.Open
FileMode.OpenOrCreate
It opens an existing file and truncates the content that already exists.
FileMode.Truncate
FileMode.CreateNew
FileMode.Open
FileMode.OpenOrCreate
This method reads a single byte from a file and returns as an integer value.
ReadByte()
Read()
WriteByte()
Write()
This method reads the specified number of bytes from a file into an array.
ReadByte()
Read()
WriteByte()
Write()
It writes the specified byte into the file.
ReadByte()
Read()
WriteByte()
Write()
It writes an array of bytes into the file.
Flush()
void Close()
WriteByte()
Write()
This method instantly writes the data into the file.
Flush()
void Close()
WriteByte()
Write()
This method closes the file, releasing the system resources that are allocated to it.
Flush()
void Close()
WriteByte()
Write()
Determines the location of the next read/write operation to take place on the file.
File Pointer
File Stream
File Buffer
File Handle
The method used to relocate the file pointer in the file
Seek
Read
Write
Open
Method that allows setting the file position indicator of file pointer to the preferred location in the file.
Seek
Read
Write
Open
Syntax for seek method
long Seek(long n, SeekOrigin location)
void Seek(long n, SeekOrigin location)
long Seek(int n, SeekOrigin location)
Seek(long n, SeekOrigin location)
It returns true if the stream can be read.
bool CanRead
bool CanSeek
bool CanTimeout
bool CanWrite
It returns true if the stream supports position requests.
bool CanRead
bool CanSeek
bool CanTimeout
bool CanWrite
It returns true if the stream can time out.
bool CanRead
bool CanSeek
bool CanTimeout
bool CanWrite
It returns true if the stream can be written.
long length
int ReadTimeout
int WriteTimeout
bool CanWrite
It contains the size of the stream.
long length
int ReadTimeout
int WriteTimeout
bool CanWrite
It indicates the time before a timeout occurs for read operations.
long length
int ReadTimeout
int WriteTimeout
bool CanWrite
It indicates the time before a timeout occurs for write operations.
long length
int ReadTimeout
int WriteTimeout
bool CanWrite
Writes characters to a stream and contains several constructors
StreamWriter
FileStream
StreamReader
StringBuilder
It is used to create a character-based output stream.
SteamWriter(Stream stream)
StreamWriter(string fileName)
StreamReader(Stream stream)
FileStream(string path, FileMode mode)
It is used to open a file directly.
SteamWriter(Stream stream)
StreamWriter(string fileName)
StreamReader(Stream stream)
FileStream(string path, FileMode mode)
It closes the file.
Close()
Flush()
Write()
WriteLine()
It instantly saves the file content from buffer to memory
Close()
Flush()
Write()
WriteLine()
Using a File stream class, this writes into the specified file.
Close()
Flush()
Write()
WriteLine()
Line by line, it writes into a file.
Close()
Flush()
Write()
WriteLine()
It is the name of an open stream such I/O devices or a file.
StreamReader(Stream stream)
StreamReader(string fileName)
StreamReader(Stream stream)
FileStream(string path, FileMode mode)
It specifies the name of the file to open.
StreamReader(Stream stream)
StreamReader(string fileName)
StreamReader(Stream stream)
FileStream(string path, FileMode mode)
From buffer to memory, it instantly saves the file content.
Flush()
Close()
Read()
ReadLine()
It closes the file and is mandatory to this class.
Flush()
Close()
Read()
ReadLine()
From the file stream, it reads the content.
Flush()
Close()
Read()
ReadLine()
From the given file stream, it reads the content line by line.
ReadToEnd()
Peek()
Seek()
ReadLine()
From the current location until the end of the stream, it reads all characters.
ReadToEnd()
Peek()
Seek()
ReadLine()
It returns the value in the stream without moving the file pointer.
ReadToEnd()
Peek()
Seek()
ReadLine()
Sets the file pointer at the desired position in a file.
ReadToEnd()
Peek()
Seek()
ReadLine()
ADO.NET
Active Data Objects
Advanced Data Objects
Abstract Data Object
ActiveX Data Objects
One of the five (5) data providers that gives data access on Microsoft SQL Server.
Data Provider for SQL Server
Data Provider for OLE DB
Data Provider for ODBC
Data Provider for Oracle
One of the five (5) data providers that is used for connecting OLE DB data source.
Data Provider for SQL Server
Data Provider for OLE DB
Data Provider for ODBC
Data Provider for Oracle
System.Data.SqlClient
Data Provider for SQL Server
Data Provider for OLE DB
Data Provider for ODBC
Data Provider for Oracle
Data Provider for SQL Server
Data Provider for OLE DB
Data Provider for ODBC
Data Provider for Oracle
Data Provider for SQL Server
Data Provider for OLE DB
Data Provider for ODBC
Data Provider for Oracle
EntityClient Provider
Data Provider for OLE DB
Data Provider for ODBC
Data Provider for Oracle
EntityClient Provider
Data Provider for OLE DB
Data Provider for ODBC
Data Provider for Oracle
It manages the data for any entity. It contains zero or more rows of data, and each value shown
in the data table is identified by the DataColumn. It also consists of primary key, foreign key, constraint, and relation information of different tables.
DataTable
DataColumn
DataRelation
DataColumnMapping
It includes a data type declaration based on the kind of data saved.
DataTable
DataColumn
DataRelation
DataColumnMapping
It is used to link two (2) DataTable classes inside the DataSet class.
DataView
DataColumn
DataRelation
DataColumnMapping
It is used to map a table name from the database to a DataTable within a DataSet.
DataView
DataColumn
DataRelation
DataColumnMapping
It is used to customize the view of the table or desired view of the rows in a DataTable.
DataView
DataColumn
DataRelation
DataColumnMapping
It can run SQL commands and perform a stored procedure—accessing and manipulating data. Data
management statements and SQL queries are wrapped in the Command object.
Command
Connection
DataAdapters
DataReaders
From the data source, it allows users to connect and disconnect. Communications with the external
data sources happen through the Connection object.
Command
Connection
DataAdapters
DataReaders
It transfers DataSets between the data source and the caller. It also acts as a connection between
the data source and DataSet, where DataAdapters contain a connection and set of Command objects that help in fetching and updating data.
Command
Connection
DataAdapters
DataReaders
It is a read-only access to data using a server-side cursor. The DataReader object is gained by
invoking the ExecuteReader method of the Command object. It requires closing the connection when using the DataReader object.
Command
Connection
DataAdapters
DataReaders
Used as wrappers for SQL statements or stored procedure calls.
SqlCommand, OleDbCommand, and ODBCCommand
SqlCommandBuilder, OleDbCommandBuilder, and ODBCCommandBuilder
SqlConnection, OleDbConnection, and ODBCConnection
SqlDataAdapter, OleDbDataAdapter, and ODBCDataAdapter
Generate SQL commands for updating database tables
Automatically generate SQL commands from a SELECT statement
SqlCommand, OleDbCommand, and ODBCCommand
SqlCommandBuilder, OleDbCommandBuilder, and ODBCCommandBuilder
SqlConnection, OleDbConnection, and ODBCConnection
SqlDataAdapter, OleDbDataAdapter, and ODBCDataAdapter
Used to connect to the database
SqlCommand, OleDbCommand, and ODBCCommand
SqlCommandBuilder, OleDbCommandBuilder, and ODBCCommandBuilder
SqlConnection, OleDbConnection, and ODBCConnection
SqlDataAdapter, OleDbDataAdapter, and ODBCDataAdapter
Handle interaction between DataSet and data source
Help in executing different SQL commands to populate a DataSet and update the data source
SqlDataReader, OleDbDataReader, and ODBCDataReader
SqlParameter, OleDbParameter, and ODBCParameter
SqlTransaction, OleDbTransaction, and ODBCTransaction
SqlDataAdapter, OleDbDataAdapter, and ODBCDataAdapter
Used as a forward-only, read-only access to data using a cursor.
SqlDataReader, OleDbDataReader, and ODBCDataReader
SqlParameter, OleDbParameter, and ODBCParameter
SqlTransaction, OleDbTransaction, and ODBCTransaction
SqlDataAdapter, OleDbDataAdapter, and ODBCDataAdapter
Define a parameter to a stored procedure.
SqlDataReader, OleDbDataReader, and ODBCDataReader
SqlParameter, OleDbParameter, and ODBCParameter
SqlTransaction, OleDbTransaction, and ODBCTransaction
SqlDataAdapter, OleDbDataAdapter, and ODBCDataAdapter
Represent transactions to be made in data source
SqlDataReader, OleDbDataReader, and ODBCDataReader
SqlParameter, OleDbParameter, and ODBCParameter
SqlTransaction, OleDbTransaction, and ODBCTransaction
SqlDataAdapter, OleDbDataAdapter, and ODBCDataAdapter
It includes all generic data access classes.
It includes classes that are shared or overridden by individual data providers.
It includes Entity Framework classes.
It includes LINQ to SQL provider classes.
It includes ODVC provider classes.
It includes OLE DB provider classes.
It includes new base classes and connection factory classes.
It includes new generic interfaces and classes for SQL Server data access.
It includes SQL Server provider classes.
It includes SQL Server data types.
CREATE DATABASE db_name;
Query for creating a database
Query for dropping a database
Query for creating a database table
Query for dropping a database table
DROP DATABASE db_name;
Query for creating a database
Query for dropping a database
Query for creating a database table
Query for dropping a database table
CREATE TABLE table_name ( column1 datatype, column2 datatype,
column3 datatype,...);
Query for creating a database
Query for dropping a database
Query for creating a database table
Query for dropping a database table
DROP TABLE table_name;
Query for creating a database
Query for dropping a database
Query for creating a database table
Query for dropping a database table
The first step in accessing data from the database (C-O-C-U-C)
Create a connection to the specified server.
Open a connection using the SqlConnection object.
Create a command using the SqlCommand object.
Use and create a DataReader or DataAdapter object.
Call the Close() method to close the connection and release the resources.
The SECOND step in accessing data from the database (C-O-C-U-C)
Create a connection to the specified server.
Open a connection using the SqlConnection object.
Create a command using the SqlCommand object.
Use and create a DataReader or DataAdapter object.
Call the Close() method to close the connection and release the resources.
The THIRD step in accessing data from the database (C-O-C-U-C)
Create a connection to the specified server.
Open a connection using the SqlConnection object.
Create a command using the SqlCommand object.
Use and create a DataReader or DataAdapter object.
Call the Close() method to close the connection and release the resources.
The FOURTH step in accessing data from the database (C-O-C-U-C)
Create a connection to the specified server.
Open a connection using the SqlConnection object.
Create a command using the SqlCommand object.
Use and create a DataReader or DataAdapter object.
Call the Close() method to close the connection and release the resources.
The FIFTH step in accessing data from the database (C-O-C-U-C)
Create a connection to the specified server.
Open a connection using the SqlConnection object.
Create a command using the SqlCommand object.
Use and create a DataReader or DataAdapter object.
Call the Close() method to close the connection and release the resources.
This class is used to open a connection using the Open() method. The connection can be closed by calling the Close() method.
SqlConnection
SqlCommand
SqlDataReader
SqlDataSet
A property that is used to read or assign the connection string to be used by the SqlConnection class.
ConnectionString
DataSource
Database
State
A read-only property that returns the name of the SQL Server instance.
ConnectionString
DataSource
Database
State
A read-only property that returns the name of the database.
ConnectionString
DataSource
Database
State
A read-only property that returns the current state of the connection.
ConnectionString
DataSource
Database
State
This class is used to perform desired processing on the database. It allows executing any direct T-SQL or stored procedure on the server.
SqlConnection
SqlCommand
SqlDataReader
SqlParameterCollection
This method executes the command but does not return output.
ExecuteNonQuery
ExecuteReader
SqlDataReader
ExecuteRow
ExecuteScalar
This method executes the command and returns a DataReader object based on the SQL statement.
ExecuteNonQuery
ExecuteReader
SqlDataReader
ExecuteRow
ExecuteScalar
This object is forward-only and read-only cursor that can be iterated through to fetch the rows in it.
ExecuteNonQuery
ExecuteReader
SqlDataReader
ExecuteRow
ExecuteScalar
It executes the command and returns the SqlRecord object that contains a single returned row.
ExecuteNonQuery
ExecuteReader
SqlDataReader
ExecuteRow
ExecuteScalar
It executes the command and returns the first column of the first row in the result set.
ExecuteNonQuery
ExecuteReader
SqlDataReader
ExecuteRow
ExecuteScalar
It gets or sets the SqlConnection class that can be used by the Command object.
Connection
CommandText
CommandType
CommandTrial
It gets or sets the stored procedure or the T-SQL statement.
Connection
CommandText
CommandType
CommandTrial
It indicates the way the CommandText property should be interpreted.
Connection
CommandText
CommandType
CommandTrial
It refers to a collection of parameters that is connected with SqlCommand.
SqlConnection
SqlCommand
SqlDataReader
SqlParameterCollection
Query for selecting all the data of the table
SELECT * FROM table_name;
SELECT column1, column2, column3,... FROM table_name;
CREATE TABLE table_name ( column1 datatype, column2 datatype,
column3 datatype,...);
DROP TABLE table_name;
Query for selecting specific columns of the table
SELECT * FROM table_name;
SELECT column1, column2, column3,... FROM table_name;
CREATE TABLE table_name ( column1 datatype, column2 datatype,
column3 datatype,...);
DROP TABLE table_name;
Query for inserting data for all the columns of the table
INSERT INTO table_name VALUES(value1, value2, value3,... );
INSERT INTO table_name (column1, column2, column3, ... ) VALUES(value1, value2, value3, ... );
CREATE TABLE table_name ( column1 datatype, column2 datatype,
column3 datatype,...);
DROP TABLE table_name;
Query for inserting data for specified column names
INSERT INTO table_name VALUES(value1, value2, value3,... );
INSERT INTO table_name (column1, column2, column3, ... ) VALUES(value1, value2, value3, ... );
CREATE TABLE table_name ( column1 datatype, column2 datatype,
column3 datatype,...);
DROP TABLE table_name;
Query for updating data.
UPDATE table_name SET column1 = value1, column2 = value2, column3 = value3 WHERE condition;
INSERT INTO table_name (column1, column2, column3, ... ) VALUES(value1, value2, value3, ... );
CREATE TABLE table_name ( column1 datatype, column2 datatype,
column3 datatype,...);
DROP TABLE table_name;
It adds the specified SqlParameter object to the SqlParameterCollection and contains two (2) arguments: string paramaterName and SqlDbType.
Add()
AddWithValue()
Insert()
SetParameter()
It adds a value to the end of the SqlParameterCollection and contains two (2) arguments, a string parameterName and an object, that includes the value of that parameter.
Add()
AddWithValue()
Insert()
SetParameter()
The correct syntaxt for Add()
public SqlParameter Add(string paramterName, SqlDbtype sqlDbType);
public void Add(string paramterName, SqlDbType sqlDbType);
public SqlParameter Add(string paramterName, object value);
public void Add(SqlParameter parameter);
The correct syntax for AddWithValues()
public SqlParameter AddWithValue(string parameterName, object value);
public void AddWithValue(string parameterName, object value);
public SqlParameter AddWithValue(object value, string parameterName);
public SqlParameter AddWithValue(SqlDbType dataType, object value);
It is used to modify or update an existing record. It uses the WHERE clause to determine the number of records that will be updated.
SQL UPDATE
SQL INSERT
SQL DELETE
SQL SELECT
