0% found this document useful (0 votes)
1K views

Assignment For Course-Gad 22034

Here is an example of a .NET application that connects to a Microsoft Access database: 1. Create a new Console Application project in Visual Studio. 2. Add references to System.Data and System.Data.OleDb assemblies. 3. Create a connection string to the Access database: string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\mydatabase.accdb;"; 4. Open a connection: OleDbConnection connection = new OleDbConnection(connectionString); connection.Open(); 5. Write a query to select data: string query = "SELECT * FROM Customers";
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

Assignment For Course-Gad 22034

Here is an example of a .NET application that connects to a Microsoft Access database: 1. Create a new Console Application project in Visual Studio. 2. Add references to System.Data and System.Data.OleDb assemblies. 3. Create a connection string to the Access database: string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\mydatabase.accdb;"; 4. Open a connection: OleDbConnection connection = new OleDbConnection(connectionString); connection.Open(); 5. Write a query to select data: string query = "SELECT * FROM Customers";
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

ASSIGNMENT FOR COURSE-GAD 22034

Work from Home


CO4I -SUMMER-2020
Name: Vishal S Kesharwani
Roll No. 11
Enrolment No. 1812420115 (1st Batch)

Q.1.What is .Net framework?


Answer:
.Net Framework: .NET Framework is a software framework developed by Microsoft that runs primarily on
Microsoft Windows. It includes a large class library named as Framework Class Library and provides language
interoperability across several programming languages. .NET Framework is used to create and run software
applications. .NET apps can run on many operating systems, using different implementations of .NET. .NET
Framework is used for running .NET apps on Windows. Software developers and the users of their
applications both use .NET Framework:

 Users of applications built with the .NET Framework need to have .NET Framework installed. In
most cases, .NET Framework is already installed with Windows. If needed, you can download .NET
Framework.
 Software developers use .NET Framework to build many different types of applications—websites,
services, desktop apps, and more with Visual Studio. Visual Studio is an integrated development
environment (IDE) that provides development productivity tools and debugging capabilities. See
the .NET customer showcase for examples of what people are building with .NET.

Q.2.What is an Assembly? Explain different types of Assemblies?


Answer:
Assembly: It is the unit of deployment for the Microsoft .NET framework and takes the form of an
executable (.exe) file or dynamic-link library (DLL). Assembly is logical unit of code. All the .NET
assemblies contain the definition of types, versioning information for the type, meta-data, and
manifest. Assemblies are a collection of Single-File and Multiple-File. An assembly is the primary unit of
deployment, security, and version control in the .NET Framework. The .NET Framework (version 2.0)
includes 51 assemblies.
Before we can use a class contained in an assembly in our application, we must add a reference to the
assembly.
 mscorlib.dll
 System.dll
 System.Configuration.dll
 System.Web.dll
 System.Data.dll
 System.Web.Services.dll
 System.Xml.dll
In .Net 3 types of Assemblies are available:
1. Private Assemblies : Private Assemblies are designed to be used by one application and 
                                   must reside in that application's directory or subdirectory.

2. Shared Assemblies: Microsoft offers the shared assembly for those components that must 
                                  be distributed. It centered around two principles. 
                                  Firstly, called side-by-side execution, allows the CLR to house multiple 
                                  versions of the same component on a single machine.
                                  Secondly, termed binding, ensures that clients obtain the version of the 
                                  component they expect.

3. Satellite Assembly: A satellite Assembly is defined as an assembly with resources only, no 
                                 executable code.
To build an assembly in Visual Studio, on the Build menu, select Build.

Q.3.What is an Interface?
Answer:
Interface is a type which contains only the signatures of methods, delegates or events, it has no
implementation. Implementation of the methods is done by the class which implements
the interface. Interface is a contract that defines the signature of the functionality.
An interface contains definitions for a group of related functionalities that a non-abstract class or a
struct must implement. By using interfaces, you can, for example, include behavior from multiple
sources in a class.
Q.4. What is CLR?
Answer:
The Common Language Runtime (CLR), the virtual machine component of Microsoft .NET framework,
manages the execution of .NET programs. Just-in-time compilation converts the managed
code (compiled intermediate language code), into machine instructions which are then executed on
the CPU of the computer.[1] The CLR provides additional services including memory management, type
safety, exception handling, garbage collection, security and thread management. All programs written
for the .NET framework, regardless of programming language, are executed by the CLR. All versions of
the .NET framework include CLR. The CLR team was started June 13, 1998.

Components of .NET CLR 


The key components of CLR includes the following: 

 Class Loader - Used to load all classes at run time.


 MSIL to Native code - The Just In Time (JTI) compiler will convert MSIL code into native code. 
 Code Manager - It manages the code at run time. 
 Garbage Collector - It manages the memory. Collect all unused objects and deallocate them to
reduce memory. 
 Thread Support - It supports multithreading of our application. 
 Exception Handler - It handles exceptions at run time.
Q.5. What is MSIL?
Answer:
MSIL stands for Microsoft Intermediate Language. We can call it as Intermediate Language (IL) or
Common Intermediate Language (CIL). During the compile time , the compiler convert the source code
into Microsoft Intermediate Language (MSIL) .Microsoft Intermediate Language (MSIL) is a CPU-
independent set of instructions that can be efficiently converted to the native code. During the runtime
the Common Language Runtime (CLR)'s Just In Time (JIT) compiler converts the Microsoft Intermediate
Language (MSIL) code into native code to the Operating System.

Q.6.What is meant by Managed and Unmanaged code?


Answer:
Managed Code: Managed Code in Microsoft .Net Unmanaged Code: A code which is directly
Framework, is the code that has executed by executed by the operating system is known
the Common Language Runtime (CLR) as Unmanaged code. It always aimed for the
environment. On the other hand Unmanaged Code processor architecture and depends upon
is directly executed by the computer's CPU. Data computer architecture. When this code is compiled
types, error-handling mechanisms, creation and it always tends to get a specific architecture and
destruction rules, and design guidelines vary
always run on that platform, in other words,
between managed and unmanaged object models.
whenever you want to execute the same code for
The execution of managed code is as shown in the
below image, the source code is written in any the different architecture you have to recompile
language of .NET Framework. that code again according to that architecture. The
execution of unmanaged code is as shown in the
below image:
Q.7.What is VB.NET?
Answer:
Visual Basic .NET (VB.NET) is a multi-paradigm, object-oriented programming language, implemented
on the .NET Framework. Microsoft launched VB.NET in 2002 as the successor to its original Visual
Basic language. Although the ".NET" portion of the name was dropped in 2005, this article uses "Visual
Basic [.NET]" to refer to all Visual Basic languages released since 2002, in order to distinguish between
them and the classic Visual Basic. Along with Visual C#, it is one of the two main languages targeting
the .NET framework.

Advantages of VB.NET
The following are the pros/benefits you will enjoy for coding in VB.NET:

 Your code will be formatted automatically.


 You will use object-oriented constructs to create an enterprise-class code.
 You can create web applications with modern features like performance counters, event logs,
and file system.
 You can create your web forms with much ease through the visual forms designer. You will also
enjoy drag and drop capability to replace any elements that you may need.
 You can connect your applications to other applications created in languages that run on the
.NET framework.
 You will enjoy features like docking, automatic control anchoring, and in-place menu editor all
good for developing web applications.

Q.8.What is ADO.NET?
Answer:
ADO.NET is a data access technology from the Microsoft .NET Framework that provides
communication between relational and non-relational systems through a common set of components.
[1]
 ADO.NET is a set of computer software components that programmers can use to access data and
data services from a database. It is a part of the base class library that is included with the Microsoft
.NET Framework. It is commonly used by programmers to access and modify data stored in relational
database systems, though it can also access data in non-relational data sources. ADO.NET is sometimes
considered an evolution of ActiveX Data Objects (ADO) technology, but was changed so extensively
that it can be considered an entirely new product.
The following figure shows the ADO.NET objects at a glance:
Q.9. Give an example of a .NET application which connects to Microsoft Access Database using
Ado.net classes.
Answer:
Important classes of ADO.NET
 Connection
 Command
 Datareader
 DataAdapter
 Dataset
The .Net Framework provides three important Data Providers for ADO.NET. They are the Microsoft SQL
Server Data Provider, OLEDB Data Provider and ODBC Data Provider. Connection, Command,
DataReader, and DataAdapter objects are data provider.
If you are using MS SQL server as a database, then use System.Data.SqlClient.
If you are using Oracle server as a database, then use System.Data. OracleClient.

When you want to connect to a database, you will use the Connection object. In this part you will learn
to connect to databases of Ms. Access and SQL Server. To connect to Ms. Access databases, we use
System.Data.Oledb class. And to connect to SQL Server databases, we use System.Data.SqlClient class.
 
Example: Connect to MS Access database
Dim cn As OleDb.OleDbConnection
'Create Connection object
 
cn = New OleDb.OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0; Data Source=" &
Application.StartupPath & "\dbimages.mdb")
'Create Connection object
cn.Open()
OR
'Create Connection object
Dim cn As New OleDb.OleDbConnection
'Set connection string
cn.ConnectionString="Provider=Microsoft.Jet.Oledb.4.0; Data Source=" & Application.StartupPath
& "\dbimages.mdb"
cn.Open()
 
This code will connect to Ms. Access database “dbimages.mdb” located in start up path of the current
project. The database contains a table named tblimages that store image ID and its path.

If the database has password protection (e.g. 123), the connection string should be modified to:

cn.ConnectionString="Provider=Microsoft.Jet.Oledb.4.0; Data Source=" & Application.StartupPath &


"\dbimages.mdb; Jet OLEDB:Database Password=123;"

For newer Ms. Access database (2007+), you need to use another provider called
Microsoft.ACE.OLEDB.12.0 rather than Microsoft.Jet.Oledb.4.0.
Q.10.What is a Dataset?
Answer:
DataSet is an in-memory representation of data. It is a disconnected, cached set of records that are
retrieved from a database. When a connection is established with the database, the data adapter
creates a dataset and stores data in it. After the data is retrieved and stored in a dataset, the
connection with the database is closed. This is called the 'disconnected architecture'. The dataset
works as a virtual database containing tables, rows, and columns.

Following table shows some important properties of the DataSet class:

Properties Description

CaseSensitive Indicates whether string comparisons within the data tables are case-sensitive.

Container Gets the container for the component.

DataSetName Gets or sets the name of the current data set.

DefaultViewManager Returns a view of data in the data set.

DesignMode Indicates whether the component is currently in design mode.

EnforceConstraints Indicates whether constraint rules are followed when attempting any update operation.

Events Gets the list of event handlers that are attached to this component.

ExtendedProperties Gets the collection of customized user information associated with the DataSet.

HasErrors Indicates if there are any errors.

IsInitialized Indicates whether the DataSet is initialized.

Locale Gets or sets the locale information used to compare strings within the table.

Namespace Gets or sets the namespace of the DataSet.

Prefix Gets or sets an XML prefix that aliases the namespace of the DataSet.

Relations Returns the collection of DataRelation objects.

Tables Returns the collection of DataTable objects.

Q.11.What is DataAdapter?
Answer:
This is integral to the working of ADO.Net since data is transferred to and from a database through
a data adapter. It retrieves data from a database into a dataset and updates the database. When
changes are made to the dataset, the changes in the database are actually done by the data
adapter.

The DataAdapter can perform Select , Insert , Update and Delete SQL operations in the Data Source.
The Insert , Update and Delete SQL operations , we are using the continuation of the Select command
perform by the DataAdapter. That is the DataAdapter uses the Select statements to fill a DataSet and
use the other three SQL commands (Insert, Update, delete) to transmit changes back to the Database.
From the following links describe how to use SqlDataAdapter and OleDbDataAdapter in detail.

 SqlDataAdapter
 OleDbDataAdapter

Q.12.What are DataReaders?


Answer:
DataReader Object in ADO.NET is a stream-based , forward-only, read-only retrieval of query results
from the Data Sources , which do not update the data. The DataReader cannot be created directly from
code, they can created only by calling the ExecuteReader method of a Command Object.

DataReader Object in ADO.NET is a stream-based , forward-only, read-only retrieval of query results


from the Data Source, which do not update the data. The DataReader cannot be created directly from
code, they created only by calling the ExecuteReader method of a Command Object.

DataReader = Command.ExecuteReader()
DataReader Object provides a connection oriented data access to the data Sources. A Connection
Object can contain only one DataReader at a time and the connection in the DataReader remains open
and cannot be used for any other purpose while data is being accessed. When started to read from a
DataReader it should always be open and positioned prior to the first record. The Read() method in the
DataReader is used to read the rows from DataReader and it always moves forward to a new valid row,
if any row exist .
DataReader.Raed()
There are two types of DataReader in ADO.NET. They are SqlDataReader and the OleDbDataReader.
The System.Data.SqlClient and System.Data.OleDb are containing these DataReaders respectively.
From the following link you can see in details about these classes.
 SqlDataReader
 OleDbDataReader

Q.13.What are DataProviders?


Answer:
Data provider is used to connect to the database, execute commands and retrieve the record. It is
lightweight component with better performance. It also allows us to place the data into DataSet to
use it further in our application.

The .NET Framework provides the following data providers that we can use in our application.

.NET Framework data provider Description

.NET Framework Data It provides data access for Microsoft SQL Server. It requires
Provider for SQL Server the System.Data.SqlClient namespace.

.NET Framework Data It is used to connect with OLE DB. It requires


Provider for OLE DB the System.Data.OleDb namespace.

.NET Framework Data It is used to connect to data sources by using ODBC. It requires
Provider for ODBC the System.Data.Odbc namespace.

.NET Framework Data It is used for Oracle data sources. It uses


Provider for Oracle the System.Data.OracleClient namespace.

EntityClient Provider It provides data access for Entity Data Model applications. It requires
the System.Data.EntityClient namespace.

.NET Framework Data It provides data access for Microsoft SQL Server Compact 4.0. It requires
Provider for SQL Server the System.Data.SqlServerCe namespace.
Compact 4.0.

.NET Framework Data Providers Objects

Following are the core object of Data Providers.

Object Description

Connection It is used to establish a connection to a specific data source.

Command It is used to execute queries to perform database operations.

DataReader It is used to read data from data source. The DbDataReader is a base class for all DataReader
objects.

DataAdapter It populates a DataSet and resolves updates with the data source. The base class for all
DataAdapter objects is the DbDataAdapter class.
Q.14. What is the difference between Connected and Disconnected environment?
Answer:
Connected environment Disconnected environment
The architecture of ADO.net, in which connection The architecture of ADO.net in which data retrieved
must be opened to access the data retrieved from from database can be accessed even when
database is called as connected architecture. connection to database was closed is called as
disconnected architecture.
It is connection oriented. It is dis_connection oriented.

Datareader: DataReader is Connected Architecture DataSet:DataSet is DisConnected Architecture since


since it keeps the connection open until all rows are all the records are brought at once and there is no
fetched one by one need to keep the connection alive

Connected methods gives faster performance Disconnected get low in speed and performance.

connected can hold the data of single table disconnected can hold multiple tables of data

connected you need to use a read only forward disconnected you cannot
only data reader
Data Reader can't persist the data Data Set can persist the data

It is Read only, we can't update the data. We can update data


Q.15.What is a Datatable?
Answer:
A DataTable represents one table of in-memory relational data; the data is local to the .NET-based
application in which it resides, but can be populated from a data source such as Microsoft SQL Server
using a DataAdapter. Data Table:

DataTable represents relational data into tabular form. ADO.NET provides a DataTable class to create
and use data table independently. It can also be used with DataSet also. Initially, when we create
DataTable, it does not have table schema. We can create table schema by adding columns and
constraints to the table. After defining table schema, we can add rows to the table.

We must include System.Data namespace before creating DataTable.

DataTable Class Signature


1. public class DataTable : System.ComponentModel.MarshalByValueComponent, System.ComponentMo
del.IListSource,  
2. System.ComponentModel.ISupportInitializeNotification, System.Runtime.Serialization.ISerializable,  
3. System.Xml.Serialization.IXmlSerializable  

DataTable Properties

The following table contains the DataTable class properties.

Property Description

Columns It is used to get the collection of columns that belong to this table.

Constraints It is used to get the collection of constraints maintained by this table.

DataSet It is used to get the DataSet to which this table belongs.

DefaultView It is used to get a customized view of the table that may include a filtered view.

HasErrors It is used to get a value indicating whether there are errors in any of the rows in the table
of the DataSet.

MinimumCapacit It is used to get or set the initial starting size for this table.
y

PrimaryKey It is used to get or set an array of columns that function as primary keys for the data table.

Rows It is used to get the collection of rows that belong to this table.

TableName It is used to get or set the name of the DataTable.


Q.16. List tools of toolbox in vb.net with working.
Answer:
Following table lists the Common Controls listed in the ToolBox.

Images Control Name Description


Pointer Used to move and resize controls and forms.
Button This Control triggers an action when accessed.
Check Box Control that has values either true or false
CheckedList Box Lists check box next to each item
Combo Box A combination of list and text box controls that enables to select as well as edit
text.
DateTimePicker Display a calender picker to choose the day and date.
Label Displays a label text.
LinkLabel Displays a label with a link text.
List Box Control that lists number of items.
List View Extension of ListBox control with options to add icons,headings.
Masked Text Box Uses a Mask to differetiate proper and improper text input.
MonthCalendar Enable to select date at runtime
Notify Icon Displays an icon in the Windows Tray
NumericUpDow Allows to input a integer of specific decimal places within a specific range.
n
Picture Box Display image files
Progress Bar Display the progress of a task.
Radio Button Allows to choose a choice from a group of choices.
Rich TextBox Allows to edit, input rich text.
Text Box Control used to input or display text.
ToolTip Displays tooltip text.
TreeView Displays the hierarchy of nodes.
WebBrowser Allows to open an html document in form.
Q.17. All the questions given in Lab Manual.

Date Of Submission:

Signature:

You might also like