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);

39 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. Thanks for sharing use interview questions on .Net technology. While preparing for my job interview, your article helped me a lot to sharpen my skills and do well in my interview. One of trainer from leading dot net training in Chennai suggests me about your site.

    ReplyDelete
  3. It is a one of the great discussion which is very essential for me as well. I must follow the handy discussion and sure that the content will be very useful to me as well. Keep it up.
    RPA Training Institute in Chennai | UI Path Training Institute in Chennai | Blue Prism Training Institute in Chennai

    ReplyDelete
  4. 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
  5. 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
  6. the blog is very useful, interesting and informative. thank you for sharing the blog with us. keep on updating. Best web designing and development courses in kanchipuram|

    ReplyDelete
  7. the blog is very useful, interesting and informative. thank you for sharing the blog with us. keep on updating. Best Tally ERP 9 Training institute in kanchipuram|

    ReplyDelete
  8. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site. Best Graphic Designing Training Institute in kanchipuram

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

    Best Python Training Academy in Kanchipuram

    ReplyDelete
  10. I think this is the best article today. Thanks for taking your own time to discuss this topic, I feel happy about that curiosity has increased to learn more about this topic. Keep sharing your information regularly for my future reference. Best Web Designing and Development Training Institute in kanchipuram|

    ReplyDelete
  11. 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
  12. Awesome post. Really you are shared very informative concept... Thank you for sharing. Keep on updating...
    Best ccnp Training Academy in Kanchipuram

    ReplyDelete
  13. I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
    Best Graphic Designing Training Institute in in Kanchipuram

    ReplyDelete
  14. Nice post... Really you are done a wonderful job. Thanks for sharing such wonderful information with us. Please keep on updating...
    Best Graphic designing Training Institute in in Kanchipuram

    ReplyDelete
  15. This information is very useful and innovative..I gained more knowledge from this.Thanks for the nice information its very useful to read your blog...
    Best web designing Training Institute in in Kanchipuram

    ReplyDelete
  16. 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 dally erp 9 Training Institute in in Kanchipuram

    ReplyDelete
  17. Awesome Post! I like writing style, the way you described the topics throughout the post. I hope many web reader will keep reading your post at the end, Thanks for sharing your view.
    Best web design Training Institute in Kanchipuram

    ReplyDelete
  18. Your article was so impressive and informative. Its very interesting to read. Thanks for sharing,
    Best web design Training Institute in Kanchipuram

    ReplyDelete
  19. very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing
    Best graphic designing Training Institute in Kanchipuram

    ReplyDelete
  20. 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
  21. 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
  22. Nice blog. I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.
    Best java Training Institute in Kanchipuram

    ReplyDelete
  23. 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
  24. Excellent post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
    Best web Designing Training Training Institute in Kanchipuram

    ReplyDelete
  25. You created an Impressive blog with lovely information.You made a really very useful article..Thanks for sharing such a wonderful blog...
    Best C++ Training Training Institute in Kanchipuram

    ReplyDelete
  26. Hi, am a big follower of your blog. I am really happy to found such a helpful and fascinating post that is written in well manner. Thanks for sharing such an informative post. keep update your blog.
    Best UIPath Robotic Process Automation in Training Institute in Kanchipuram

    ReplyDelete
  27. I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.
    Best web designing Training Institute in Kanchipuram

    ReplyDelete
  28. Impressive blog with lovely information. really very useful article for us thanks for sharing such a wonderful blog...
    Best Graphic designing Training Institute in Kanchipuram

    ReplyDelete
  29. 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
  30. 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
  31. The provided information’s are very useful to me. It’s a wonderful site for learning web application. Thank you for sharing this wonderful blog.
    Best Selenium Automation Course Training Institute in kanchipuram|

    ReplyDelete
  32. Your gathered Informations in this blog are very useful..This is a wonderful site for learning web application. Thank you for sharing this wonderful blog..
    Best Tally Erp 9 Course Training Institute in kanchipuram|

    ReplyDelete
  33. 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
  34. Thanks for your great information! Its interesting and informative.
    Best JAVA and J2EE Course Training Institute in kanchipuram|

    ReplyDelete
  35. This post was quite awesome and interesting to read. Congrats for your work. Thanks a lot for providing this with us. Keep on updating this with us regularly:
    Best Selenium Automation Course Training Institute in kanchipuram|

    ReplyDelete

Topics

ADFS (1) ADO .Net (2) Ajax (1) Angular (1) Angular Js (17) Angular2 (28) ASP .Net (14) Authentication (1) Azure (1) Breeze.js (1) C# (50) CD (1) CI (2) CloudComputing (1) CMS (1) CSS (2) Design_Pattern (3) DevOps (4) DI (4) Dotnet (22) Entity Framework (3) ExpressJS (4) Html (3) IIS (1) Javascript (6) Jquery (8) Lamda (3) Linq (11) Mongodb (1) MVC (50) NodeJS (7) RDLC (1) Report (1) SDLC (1) Sql Server (30) SSIS (3) SSO (1) SSRS (2) UI (1) WCF (13) Web Api (11) Web Service (1) XMl (1)