Ado .Net InterView Questions

What is Ado .Net?

Ado.Net is a Technique or an API that is used to Access any Database. ADO.Net enables a Developer to Connect to a Database, Fetch data from database, Insert, Modify or Delete Data from Database.

ADO.NET Components

1- DataSet-

2- Data provider - which is a set of components including the Connection, Command,    DataReader,and DataAdapter objects.

1- DataSet- is the disconnected Cashed set of Records of one or more tables.

2- Data provider- are used to Connect to a Database, Fetch data from database, Insert, Modify or  Delete Data from Database.

Component of DataProvider
The Connection object provides connectivity to a data source.
The Command object enables access to database commands to return data, modify data, run stored procedures, and send or retrieve parameter information.
The DataReader object Retreives Data from Database in Read Only and Farword only Mode.
The DataAdapter object provides the bridge between the DataSet object and the data source.


Which property is used to check whether a DataReader is closed or opened?

The IsClosed  property is used to check whether a DataReader is closed or opened. This property returns a true value if a Data Reader is closed, otherwise a false value is returned.



What is the use of the CommandBuilder class?

The CommandBuilder class is used to automatically update a database according to the changes made in a DataSet.



The Command object provides three methods to execute commands on the database:
ExecuteNonQuery() executes the commands and returns the number of rows affected.
ExecuteScalar() executes the commands, and returns the first column of the first row in the result set .
ExecuteReader() method returns a result set by using the DataReader object.


Connection pooling- Connection pooling increases the performance of the applications by reusing the active database connections instead of creating a new connection for every request.

Connection pooling behaviour is controlled by the connection string parameters.

The following 4 parameters control most of the connection pooling behavior.
  1. Connect Timeout
  2. Max Pool Size
  3. Min Pool Size
  4. Pooling
More about Connection Pooling : - Connection pooling refers to the task of grouping database connections in cache to make them reusable because opening new connections every time to a database is a time-consuming process. Therefore, connection pooling enables you to reuse already existing and active database connections, whenever required, and increasing the performance of your application. 


SQL Server Reporting Services (SSRS) is a server-based report generation software system. it can be used to prepare and deliver a variety of interactive and printed reports.
SSRS allows reports to be exported in various formats (Excel, PDF, word etc) 

Adding DataTable in Dataset : 
addedd two DataTable in One DataSet

DataTable dt = new DataTable();
dt.Columns.Add("ID", typeof(int));
 dt.Columns.Add("Name", typeof(string));
DataTable dt2 = new DataTable();
 dt2.Columns.Add("SID", typeof(int));
 dt2.Columns.Add("SName", typeof(string));
DataSet ds = new DataSet(); 
 ds.Tables.Add(dt);
 ds.Tables.Add(dt2);


Adding Rows in DataTable:

DataRow row = ds.Tables[0].NewRow();
//Tables[0] indicate first Table in Dataset 
row["ID"] = 1;
row["Name"] = "Suraj";
ds.Tables[0].Rows.Add(row);

Update  data in DataTable
ds.Tables[0].Rows[0]["Name"] = "Updated Name";

if Row index is unknown:
DataRow[] dRow = ds.Tables[0].Select("ID = 1");
dRow[0]["Name"] = "Updated Name";
Delete row from datatable

ds.Tables[0].Rows[0].Delete(); // deletes first Row of First DataTable

Binding Grid with DataTable

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
        <Columns>
            <asp:BoundField DataField="ID"  HeaderText="Company ID"/>
            <asp:BoundField DataField="Name" HeaderText="Company Name"/>
       </Columns>
</asp:GridView>

        DataTable dt = new DataTable();

string sqlStatement = "SELECT * FROM CompanyInfo";

          SqlCommand sqlCmd = new SqlCommand(sqlStatement, connection);

          SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);

          sqlDa.Fill(dt);



              if (dt.Rows.Count > 0)

              {

                GridView1.DataSource = dt;

                GridView1.DataBind();
              }

DataTable and DataView(Sorting and Filtering)

A datatable is an in-memory representation of a single database table.datatable stores physical data. So we can not perform filtering or Sorting in DataTable. For this we have to Create a Dataview. DataView enables you to sort or Filter Data.
EX: 
Sorting and Filtering in Dataview
_dataview.Sort = "Name ASC";
_dataview.RowFilter = "CustomerStatus = 'Active'";

Sorting and Filtering in DataTableSyntax: datatable.Select(filterExp, sortExp, rowstatevalue)
EX:  
string filterExp = "Status = 'Active'";
string sortExp = "City";
DataRow[] drarray;
drarray = dataSet1.Customers.Select(filterExp, sortExp,DataViewRowState.CurrentRows);

27 comments:

  1. Very good article. Although there is some confusion at definition of "DataSet" and "Data provider"

    ReplyDelete
    Replies
    1. may I know what type of confusion?
      See, Dataset is a Component in Which you can Store one or More DataTables from Database.

      and DataProvider is nothing but a Collection of Components: SqlConnection
      SqlCommand
      SqlDataReader
      SqlDataAdapter

      Delete
  2. Thank you for sharing such a wonderful blog...its very useful for learning dot-net and helpful for professionals preparing interviews...
    Best Microsoft Azure Training Institute in Chennai | Best Microsoft Azure Training Institute in Velachery

    ReplyDelete
  3. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.

    Microsoft Azure Training in Chennai
    Microsoft Azure Training

    ReplyDelete
  4. Wonderful post. Thank you for updating such an informative content.

    Best Python Training Academy in Kanchipuram

    ReplyDelete
  5. Really it was an awesome blog...... Very interesting to read, .It’s very helpful for me, Big thanks for the useful info and keep updating…
    Best Tally Training Academy in Kanchipuram

    ReplyDelete
  6. Awesome post. Really you are shared very informative concept... Thank you for sharing. Keep on updating...
    Best ccnp Training Academy in Kanchipuram

    ReplyDelete
  7. Wonderful article.It is to define the concepts very well.Clearly explain the information.It has more valuable information for encourage me to achieve my career goal.
    Best CCNP Training Institute in Kanchipuram

    ReplyDelete
  8. Thanks for sharing such a great information..Its really nice and informative.Great article, thanks for posting...
    Best software testing Training Institute in Kanchipuram

    ReplyDelete
  9. Wonderful article.It is to define the concepts very well.Clearly explain the information.It has more valuable information for encourage me to achieve my career goal.
    Best Web Designing and Development Training Training Institute in Kanchipuram

    ReplyDelete
  10. Wonderful article.It is to define the concepts very well.Clearly explain the information.It has more valuable information for encourage me to achieve my career goal.
    Best C++ Training Institute in Kanchipuram

    ReplyDelete
  11. Really i enjoyed very much. And this may helpful for lot of peoples. So you are provided such a
    nice and great article within this.
    Best Web Designing and Development Training Institute in Kanchipuram

    ReplyDelete
  12. Nice and good blog.. it is very useful for me to learn and understand easily.. thanks for sharing your valuable information and time.. please keep updating.
    Best tally erp9 Course Training Institute in kanchipuram|

    ReplyDelete
  13. Thanks for your great information! Its interesting and informative.
    Best JAVA and J2EE Course Training Institute in kanchipuram|

    ReplyDelete
  14. Nice and good blog. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updating...
    Best Web Technologies Course Training Institute in kanchipuram|

    ReplyDelete
  15. Superb i really enjoyed very much with this article here. Really its a amazing blog i had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent blog.
    Best Web Technologies Course Training Institute in kanchipuram|

    ReplyDelete
  16. You have done a great job, really the concept of big data was superb, its very interesting and easy to understand also.. Keep updating such a nice blog..
    Best CCNP Course Training Institute in kanchipuram|

    ReplyDelete
  17. The information you have here is really useful to make my knowledge good. It is truly supportive for us and I have accumulated some essential data from this blog.
    Best JAVA and J2EE Course Training Institute in kanchipuram|

    ReplyDelete
  18. Great blog.you put Good stuff.All the topics were explained briefly.so quickly understand for me.I am waiting for your next fantastic blog.Thanks for sharing.
    Best Tally erp9 Course Training Institute in kanchipuram|

    ReplyDelete
  19. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information, this is useful to me…
    Best Linux Certification Course Training Institute in kanchipuram|

    ReplyDelete
  20. Quite Interesting post!!! Thanks for posting such a useful post. I wish to read your upcoming post to enhance my skill set, keep blogging.
    Best Web Technologies Course Training Institute in kanchipuram|

    ReplyDelete
  21. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information, this is useful to me…no:1
    HP QTP / UFT Automation training institute in kanchipuram.

    ReplyDelete
  22. it was a wonderful chance to visit this kind of site and I am happy to know. thank you so much for giving us a chance to have this opportunity.. This is the exact information I am been searching for, Thanks for sharing the required infos with the clear update and required points.


    Dot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery





    ReplyDelete

Topics

ADFS (1) ADO .Net (1) Ajax (1) Angular (47) Angular Js (15) ASP .Net (14) Authentication (4) Azure (3) Breeze.js (1) C# (49) CD (1) CI (2) CloudComputing (2) Coding (8) CQRS (1) CSS (2) Design_Pattern (7) DevOps (4) DI (3) Dotnet (10) DotnetCore (19) Entity Framework (4) ExpressJS (4) Html (4) IIS (1) Javascript (17) Jquery (8) Lamda (3) Linq (10) microservice (4) Mongodb (1) MVC (46) NodeJS (8) React (10) SDLC (1) Sql Server (32) SSIS (3) SSO (1) TypeScript (3) UI (1) UnitTest (2) WCF (14) Web Api (16) Web Service (1) XMl (1)

Dotnet Guru Archives