Monday, 9 April 2018

011 ADO.Net Interview Question and Answer Part 2


1)How to Convert DataSet to DataReader ?

    ADO.NET table content a method CreateDataReader ,  you can convert a table to a DataReader.


DataTableReader dr=ds.Table[1].CreateDataReader();



Example


namespace ConsoleApplication1
{
           class Program
            {
                      static void Main(string[] args)
                       {
                        DataSet ds = new DataSet();
                        DataTable dt = new DataTable();

                       dt.Columns.Add("Name");
                       DataRow nr1 = dt.NewRow();
                       nr1["Name"] = "John1";
                       dt.Rows.Add(nr1);


                       DataRow nr2 = dt.NewRow();
                       nr2["Name"] = "John2";
                       dt.Rows.Add(nr2);

                      ds.Tables.Add(dt);

                     DataTableReader dr = ds.Tables[0].CreateDataReader();

                     while (dr.Read())
                      {
                           Console.WriteLine("Name=" + dr[0].ToString());
                       }

                     dr.Close();
                    Console.ReadKey();
                   }
            }
}
Output :
Name=John1
Name=John2

2)Which is fast , DataReader or DataSet ?

               DataReader is fast in compared to the DataSet. Internally Dataset  use DataReader to retrieve the data.

3)What is DAO ?


               DAO  stands for data access object. Data access Technology from Microsoft to access database like  Microsoft Access etc. It was introduced in Microsoft Visual Basic. It was connection oriented and need an active connection till the end.DAO is capable to handle local and remote database and also capable to perform insert ,update, delete  operation.

4)What is maximum pool size of a connection pool ?

               The maximum connection pool size is 100 by default. If you try to open connection more than pool size, connection Timeout error will be Occur.

5)What are the namespace used in ADO.NET ?

System.Data : This namespace provide  the basic classes for data access and manipulation. For example DataSet, datatable, DataView  comes under this lenses.

System.Data.Common :  This namespace also provide some basic functionality related to the data access and manipulation. DataAdaptor, dbconnection  classes comes under this namespace.

System.Data.Oledb : This namespace provide the classes for accessing  Microsoft Access, Microsoft Excel, Oracle etc. This namespace provide classes for OLEDB  connection,OLEDB command etc.

System.Data.SQLclient : This namespace provide the classes for accessing data Microsoft SQL server 7.0 and upper version. Namespace provides classes for SQL connection,SQL commands etc.

System.Data.Sqltype : This name space provide classes , that are quite similar to the .Net Framework variables, but quite familiar to SQL server. These classes are alternative to the .Net Framework variables, but more faster and safer. For example SqlBytes ,SqlChar,SqlFilestream etc.

6)What is
Databinding ?
 

             Databinding  is a method  to bind a data source with a control. The control will be populate, with the data from data source.  For example, bind gridview with datatable,  gridview rows and columns will be automatically populated. You do not need to add rows and columns programmatically. If you bind dropdownlist with a data source, the dropdownlist will be populated automatically no need to add item in it.Most of the asp.Net control support databinding. 

7)Which is the object, get data from data source fast and quick ?

            DataReader  is a component of.Net framework, which fetch data from data source fast and quick. Another technique is DataSet set to fetch data using DataAdapter. DataSet internally use data reader to fetch data . Data reader is a component to fetch data from a  database, it is the fastest.

7)What is ExecuteScalar ?

           A command  is executed against  a connection. Command  maybe  store procedure or a SQL query. After execution command , a complete set of data or single value on all can be return. When it is expected that is single value will be returned , ExecuteScalar is used. If more than one value is return, say it the Datatable is returned,  the first row and the first column of the Datatable will be considered,  rest will be discarded. If null value is returned, it will throw an error.ExecuteScalar  suitable for  agree gate for calculating function  like sum,multiply,average etc.

8)What is ExecuteNonQuery ?
 

A command  is fire against a connection .The command  may  contain SQL statement of stored procedures . ExecuteNonQuery  is used, it is expected that no results it will be returned after the command  execution. It is most commonly used and very popular  execution type.ExecuteNonQuery  returns number of rows affected by the query.

9)What is DataSet copy method ?
 

DataSet copy method , make a exact copy of a database  from another database.

DataSet ds1 = new DataSet();
DataSet ds2;
ds2 = ds.Copy();

copy is done bye  copying rows and columns and corresponding data,  data relation, table relation and schema from the source database to the database. It is actually clone of a source database.

10) What  is DataSet, haschanged  method ?

A DataSet have multiple table , rows and columns. It is very difficult  to detect any change is made in rows column of data.
DataSet.Haschanged()  method help ask to detect any change have been  made in the DataSet or not.
 


DataSet ds = new DataSet();
if (ds.HasChanges())
{
return;
}



This method return and indicating value if there is  any change  made in the DataSet after it has been last loaded.

11) What is disconnected data in ADO.Net ?


                   ADO.NET use DataSet , DataAdopter , Connection string  to retrieve data from database.DataAdopter takes  connection information, SQL statement  and create a channel in encrypted format to retrieve data from database.This data is filled to DataSet. DataSet hold multiple tables , rows columns and corresponding data ,DataSet  also holds  relationship schema  of the respective tables and data. This is called disconnected data,  a copy of data  in the DataSet  with SQL schema  is considered as disconnected data.

13)What are the various method  to generate and read XML ?

a)ReadXML()
b)GetXML()
c)WriteXML()

14)What is the use of System.Xml namespace ?

This  namespace provide the classes for read ,write, delete XML.System. XmlNode ,XmlAttribute  and many class to manipulate and details operation of XML file is managed .

Saturday, 7 April 2018

010 ADO.Net Interview Question and Answer Part 1


1) What is ADO.NET ?

ADO.NET is a data access Technology from Microsoft. After the introduction of .Net technology first version (
Visual Studio .NET 1.0 ) , the next version Visual Studio .NET 2003 (1.1) Microsoft added ADO.NET Technology . ADO.NET stands for ActiveX  database object. The component of ADO.NET used to connect database and manipulate data. In the earlier version of Visual Studio Microsoft provide ADO. But the introduction of.Net technology, introduce  ADO.NET. which is disconnected in nature and most advance Technology and reduce burden to the database.

2) What are the component of ADO.NET ?

Here are  the component of  ADO.NET.


Connection : Connection is a component establish a connection between database and application. Connection component accept connection string and open a database connection.


Command:Command  is some kind of SQL statement which is fired against a active connection.Command  maybe to insert , update or delete data or maybe  execution of  stored procedure.


Dataareader: DataReader is forward only ,read only component of ADO.Net.
DataReader read data, against command execution and a active connection. DataReader can read more than one result set.

DataSet: DataSet is a component to hold , a copy of fetch query result data . DataSet store the whole output of a  result set along with relationship schema in XML format.

DataAdaptor: DataAdopter  adopt data from database. It is bridging between  DataSet and database.

Datatable: Datatable hold data in a tabular format, rows and columns. One dataset can contain multiple datatables.

Dataview: When a filter condition is applied on a datatable, dataview stored the data. You can convert dataview to datatable.




3)Benefit of  ADO.NET ?

  • ADO.NET can communicate over  different kinds of environment.
  • ADO.NET is disconnected in nature, no active continuous connection is required for ADO.NET. When there is a less number of user , database is  almost free . With the growing number of user,  the disconnected architecture helps to handle  a large number of user to be connected to the database.
  • ADO.NET is fast in performance and quick response make an application user-friendly any interesting.

4) What is DataAdopter ?

DataAdopter  is a component of ADO.net , it used make a bridging  between  database and DataSet. DataAdaptor accept  connection string or active connection  and command as a parameter , and  execute the  command , after the execution , result is fill into the
DataSet.

5) What is DataReader ?


DataReader is a component of ADO.NET.
DataReader take an active connection to read data. It is forward only, need active connection until the end, multiple record set can be read by a single reader.

6) What is object pooling ?

  Object pooling is a service of MTS, it is supported by Microsoft.Net. Object pooling is a pool of object , to reuse later. When a request for object is come, the objects is first try  to allocate from the pool. This makes performance faster, reduce CPU usage and memories.

7) What is connection pooling ?
 

 Creating a connection is cost. Instead of create a new connection for each query execution ,  pool  is created  to keep live active connection, when a new connection is required, connection is assign from  this pool.

8) What is Datatable ?
 

Datatable is in memory representation of data in tabular format, rows and columns. Datatables allows filter , loop through the rows and columns. Dynamically add rows and columns and delete rows and columns ca be done programatically.

9)What is System.Data class ?
 

 System.Data is a namespace under System  namespace. System.Data  provide some basic class for data manipulation purpose. For example DataSet, Datatable, DataRow DataColumn ,DataView  only be available, when you have added System.Data in your project.

10) Can we  execute stored procedures in a DataAdopter ?

DataAdopter  accept parameters connection string and SQL command.
We can write stored procedure  name  in the  SQL comment. The Stored procedure will be executed , resultant data can be fetch to the DataSet.

11) ADO.NET support transaction processing or not ?

ADO.NET support transaction processing. One or more command  is executed against a single transaction and connection. If all successfully execute, the transaction is committed else rollback the full transaction.

12) What is the difference between ADO and  ADO.NET ?

 

  •  ADO  is based on com component,  ADO.NET is based on.Net  framework common language run time.
  •  ADO  use record set for database connection, which is connected in nature. ADO.NET use DataSet , DataReader  for data manipulation, which is disconnected in nature.
  •  ADO  use continuous connection,ADO.NET use discontinuous connection, fire command only.
  • ADO record set gives us a single view of a row , going forward, scanned database again gives the next row.ADO.NET  fetch data in a single instance table schema.

13) What is the difference between  Data Set and DataReader ?

  •  DataSet  does not need a continuous active connection , DataReader need a continuous active connection until end.
  •  DataSet is XML formatted data within in memory  allocation, DataReader  is forward only, read only component of  ADO.NET.
  • You can update Database from DataSet ,  you cannot update Database from DataReader.
  • DataSet contain multiple Datatable , DataReader  does not contain Datatable, next result set command is used to get the next set of data.
  • You can get any  Table ,row, column data form DataSet by specifying index or name properly. You need to write loop to get data from DataReader.
  • DataSet  instance is created buy new keyword . DataReader  instance is created  by command.ExecuteReader.

14) what is difference between SQL and OLEDB  provider ?

SQL and only OLEDB  both are component of.Net used for data access purpose.SQL  provider used for connecting Microsoft SQL server (7.0 and above ) and OLEDB  is use for  Excel,Access  in Oracle.
But SQL  is faster than  OLEDB.

15) What is Dataview ?

 
Datatable can be filter , and the output is stored in DataView. Dataview is an  class under .Net framework . When Datatable is filter ,
DataView come into picture. Dataview can be converted to Datatable again.










Thursday, 5 April 2018

001 AngularJS Introduction

                          AngularJS is it javaScript framework for rich  application. AngularJS is used for single page (SPA) application. AngularJS is written on javaScript. AngularJS Framework is nothing but a javaScript library .AngularJS , instead of changing inner HTML, it manipulate DOM. This makes AngularJS responsive  and faster.    
                        Before you learn AngularJS , you need a basic knowledge about
  • Javascript
  • HTML
  • CSS            

Feature of Angular JS 

  • AngularJS is cross browser compatible. It automatically handle browser specific javaScript to handle a task. 
  • AngularJS   start with </script>
  • AngularJS is free and open source framework. 
  • For each page AngularJS library need to be incorporated before using AngularJS .
  • AngularJS follows MVC architecture. It is actually client side MVC architecture with two way data binding. 
  • AngularJS is unit testable.
  • AngularJS provide reusable component. 
  • You can communicate with server by XHR/JSONP.
  • AngularJS load automatically , when a web page is load.
   AngularJS was developed by Misko Hevery in 2009.It was first version 1.0 released in 2012 ,now the code is maintained by Google.The latest version of AngularJS is 1.4.3.

Instead of several advantages, AngularJS has several disadvantage also 

  • AngularJS framework is complicated  implement and learn . 
  • As it was written on javascript ,this is not safe and secure. 
  • AngularJS is written on javascript, if user disable JavaScript, AngularJS stop working.

AngularJS  need JavaScript library to add each page , here is the link of this library.


<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>

Below is a sample AngularJS application

Example


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
         <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
         <head>
         <title>AngularJS Eaxmple 1</title>
               </head>
                         <body>
                               <h1>Eaxmple 1</h1>
                                             <div ng-app = "">
                                                      <p>Enter a String: <input type = "text" ng-model = "name"></p>
                                                      <p>Here is your string : <span ng-bind = "name"></span></p>
                                             </div>
                         </body>
</html>

Output: 













The above example is a simple application of AngularJS. This application bind input with span. When a text is entered in the input , as the Span is bind with input, the span value automatically change. You will observe that no need to write code for this purpose.

In such a way , writing very less code is required for AngularJS. You can also do the following with AngularJS.

 
  • Filter : Formatted data can be filter.    
  • JQLight: AngularJS does not depend on jQuery, JQLight is embedded in the Angular JS.
  • Routing : ngRoute provides routing and deeplinking services.Navogate between page without page loading.
  • Validation : AngularJS has library to validate data in the client end. Validation can be customised also.

  • Service : Angular services carry out some sort of task.
  • databinding : Binding of data between two object of AngularJS. AngularJS follow MVC structure, model and views are AngularJS together.
AngularJS directives are not valid HTML.You will notice , red underline below the directive.If you want to write directives
HTMl valid ,you have to add "data-" string before the directives.
For example
  • data-ng-model
  • data-ng-app
  • data-ng-controller
Below is the example of application with valid HTML


<!DOCTYPE >
<head>
         <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
</head>
<script>
          var app = angular.module("myApp", []);
          app.controller("myCtrl", function ($scope) 
       {
               $scope.firstString = "I am Learing ";
              $scope.secondString = " AngularJS ";
         });
</script>
</body>
<div data-ng-app="myApp" data-ng-controller="myCtrl">
      {{ firstString + " " + secondString }}
</div>

































 


বাঙালির বেড়ানো সেরা চারটি ঠিকানা

  বাঙালি মানে ঘোড়া পাগল | দু একদিন ছুটি পেলো মানে বাঙালি চলল ঘুরতে | সে সমুদ্রই হোক , পাহাড়ি হোক বা নদী হোক। বাঙালির ...