Sibeesh Passion

Top Menu

  • Home
  • Search
  • About
  • Privacy Policy

Main Menu

  • Articles
    • Azure
    • .NET
    • IoT
    • JavaScript
    • Career Advice
    • Interview
    • Angular
    • Node JS
    • JQuery
    • Knockout JS
    • Jasmine Framework
    • SQL
    • MongoDB
    • MySQL
    • WordPress
  • Contributions
    • Medium
    • GitHub
    • Stack Overflow
    • Unsplash
    • ASP.NET Forum
    • C# Corner
    • Code Project
    • DZone
    • MSDN
  • Social Media
    • LinkedIn
    • Facebook
    • Instagram
    • Twitter
  • YouTube
    • Sibeesh Venu
    • Sibeesh Passion
  • Awards
  • Home
  • Search
  • About
  • Privacy Policy

logo

Sibeesh Passion

  • Articles
    • Azure
    • .NET
    • IoT
    • JavaScript
    • Career Advice
    • Interview
    • Angular
    • Node JS
    • JQuery
    • Knockout JS
    • Jasmine Framework
    • SQL
    • MongoDB
    • MySQL
    • WordPress
  • Contributions
    • Medium
    • GitHub
    • Stack Overflow
    • Unsplash
    • ASP.NET Forum
    • C# Corner
    • Code Project
    • DZone
    • MSDN
  • Social Media
    • LinkedIn
    • Facebook
    • Instagram
    • Twitter
  • YouTube
    • Sibeesh Venu
    • Sibeesh Passion
  • Awards
  • Linux Azure Function Isolated Dot Net 9 YAML Template Deployment

  • Build, Deploy, Configure CI &CD Your Static Website in 5 mins

  • Post Messages to Microsoft Teams Using Python

  • Get Azure Blob Storage Blob Metadata Using PowerShell

  • Deploy .net 6 App to Azure from Azure DevOps using Pipelines

.NETADO.NETInterview
Home›.NET›Important ADO.NET Interview Questions

Important ADO.NET Interview Questions

By SibeeshVenu
October 24, 2015
2872
0
Share:

In this article we will discuss about the most asked ADO.NET interview questions and answers. If you need to know other interview questions and answers, I strongly recommend to follow this link: Interview Questions. Now in this post we are going to share the interview questions or the information which you must know as a programmer or a developer, especially if you are a Dot Net developer. I hope you will like this article.

Background

I am a dot net developer. As a dot net developer, you will always use ADO.NET to handle your data. Isn’t it. So it is important that you must know some information. We will read those basic information here. I am sharing those in the form of articles, you can always read my other interview questions here in the below links.

  • Interview Questions For Experienced and Beginner .NET Professionals
  • Infosys Interview Questions For DotNet Professionals
  • SQL Interview Questions And Answers
  • So shall we now discuss about ADO.NET interview questions?

    ADO.NET Interview Questions

    What is ADO.NET?

    ADO.NET is basically a set of components which can be used by a programmer to access and manipulate the data in a disconnected architecture. It gives the access to the data source such as SQL Server and XML. We use DataSet for the data operations in ADO.NET. It is a part of Microsoft .Net framework.

    Difference between ExecuteReader, ExecuteScalar and ExecuteNonQuery ?

    Source http://www.aspsnippets.com/Articles/Difference-between-ExecuteReader-ExecuteScalar-and-ExecuteNonQuery.aspx

    ExecuteNonQuery

    ExecuteNonQuery is basically used for operations where there is nothing returned from the SQL Query or Stored Procedure. Preferred use will be for INSERT, UPDATE and DELETE Operations.

    [csharp]
    using (SqlConnection con = new SqlConnection(constring))
    {
    using (SqlCommand cmd = new SqlCommand("DELETE FROM Persons WHERE Name = @Name", con))
    {
    cmd.CommandType = CommandType.Text;
    cmd.Parameters.AddWithValue("@Name", name);
    con.Open();
    int rowsAffected = cmd.ExecuteNonQuery();
    con.Close();
    }
    }
    [/csharp]

    Execute Scalar

    ExecuteScalar is a handy function when you want to just need one Cell value i.e. one column and one row.
    For example in a case where I need to get the City of a person based on its Name.

    [csharp]
    using (SqlConnection con = new SqlConnection(constring))
    {
    using (SqlCommand cmd = new SqlCommand("SELECT City FROM Persons WHERE Name=@Name", con))
    {
    cmd.CommandType = CommandType.Text;
    cmd.Parameters.AddWithValue("@Name", name);
    con.Open();
    object o = cmd.ExecuteScalar();
    if (o != null)
    {
    string city = o.ToString();
    }
    con.Close();
    }
    }
    [/csharp]

    Execute Reader

    ExecuteReader is strictly used for fetching records from the SQL Query or Stored Procedure i.e. SELECT Operation.
    Example would be fetching Name City for all records in the Person Table.

    [csharp]
    using (SqlConnection con = new SqlConnection(constring))
    {
    using (SqlCommand cmd = new SqlCommand("SELECT Name, City FROM Persons", con))
    {
    cmd.CommandType = CommandType.Text;
    con.Open();
    SqlDataReader dr = cmd.ExecuteReader();
    while (dr.Read())
    {
    string name = dr["Name"].ToString();
    string city = dr["City"].ToString();
    Response.Write("Name: " + name);
    Response.Write("City: " + city);
    }
    con.Close();
    }
    }
    [/csharp]

    What are Data Reader, Dataset & Data Adapter ? Explain the differences?

    Data Reader

    Data Reader is used to read the data from database and it is a read and forward only connection oriented architecture during fetch the data from database. Data Reader is used to iterate through result set that came from server and it will read one record at a time because of that memory consumption will be less and it will fetch the data very fast when compared with dataset. Generally we will use Execute Reader object to bind data to data reader.

    [csharp]
    using (SqlConnection con = new SqlConnection("Connectionstring"))
    {
    con.Open();
    SqlCommand cmd = new SqlCommand("Select UserName,LastName,Location FROM UserInformation", con);
    SqlDataReader dr = cmd.ExecuteReader();
    }
    [/csharp]

    Dataset

    Dataset is a disconnected orient architecture that means there is no need of active connections during work with datasets and it is a collection of Data Tables and relations between tables. It is used to hold multiple tables with data. You can select data form tables, create views based on table and ask child rows over relations. Also Dataset provides you with rich features like saving data as XML and loading XML data.

    [csharp]
    SqlCommand cmd = new SqlCommand("select UserName,LastName,Location from UserInformation", con);
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    DataSet ds = new DataSet();
    da.Fill(ds);
    [/csharp]

    Data Adapter

    DataAdapter will acts as a Bridge between DataSet and database. This dataadapter object is used to read the data from database and bind that data to dataset. Dataadapter is a disconnected oriented architecture.

    [csharp]
    SqlCommand cmd = new SqlCommand("select UserName,LastName,Location from UserInformation", con);
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    DataSet ds = new DataSet();
    da.Fill(ds);
    [/csharp]

    ADO stands for?

    ActiveX Data Object

    What are the main objects used in ADO.NET?

    Dataset

    Dataset is a disconnected orient architecture that means there is no need of active connections during work with datasets and it is a collection of Data Tables and relations between tables. It is used to hold multiple tables with data. You can select data form tables, create views based on table and ask child rows over relations. Also Dataset provides you with rich features like saving data as XML and loading XML data.

    DataReader

    Data Reader is used to read the data from database and it is a read and forward only connection oriented architecture during fetch the data from database. Data Reader is used to iterate through result set that came from server and it will read one record at a time because of that memory consumption will be less and it will fetch the data very fast when compared with dataset. Generally we will use Execute Reader object to bind data to data reader.

    That’s all. Have a great day.

    Conclusion

    Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.

    Your turn. What do you think?

    A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.

    Kindest Regards
    Sibeesh Venu

    TagsADO.NETCareer AdviceDot NetImportant ADO.NET Interview QuestionsInterview
    Previous Article

    SQL Interview Questions And Answers

    Next Article

    C sharp Interview Questions And Answers

    0
    Shares
    • 0
    • +
    • 0
    • 0
    • 0

    SibeeshVenu

    I am Sibeesh Venu, an engineer by profession and writer by passion. Microsoft MVP, Author, Speaker, Content Creator, Youtuber, Programmer.

    Related articles More from author

    • Failure-Success
      Career AdviceHow to

      How To Be A Successful Software Engineer

      March 21, 2016
      By SibeeshVenu
    • DatabaseInterviewSQL

      SQL Interview Questions And Answers

      October 24, 2015
      By SibeeshVenu
    • Career AdviceVideos

      Video: How to be a successful software engineer

      April 22, 2017
      By SibeeshVenu
    • Career Advice

      One Tip Which Can Boost Your Career to the Next Level

      July 12, 2018
      By SibeeshVenu
    • Career AdviceStories

      Story of a professional

      June 27, 2016
      By SibeeshVenu
    • Interview

      Most common interview questions which may be asked in all interviews

      May 26, 2018
      By SibeeshVenu
    0

    My book

    Asp Net Core and Azure with Raspberry Pi Sibeesh Venu

    YouTube

    MICROSOFT MVP (2016-2022)

    profile for Sibeesh Venu - Microsoft MVP

    Recent Posts

    • Linux Azure Function Isolated Dot Net 9 YAML Template Deployment
    • Build, Deploy, Configure CI &CD Your Static Website in 5 mins
    • Easily move data from one COSMOS DB to another
    • .NET 8 New and Efficient Way to Check IP is in Given IP Range
    • Async Client IP safelist for Dot NET
    • Post Messages to Microsoft Teams Using Python
    • Get Azure Blob Storage Blob Metadata Using PowerShell
    • Deploy .net 6 App to Azure from Azure DevOps using Pipelines
    • Integrate Azure App Insights in 1 Minute to .Net6 Application
    • Azure DevOps Service Connection with Multiple Azure Resource Group

    Tags

    Achievements (35) Angular (14) Angular 5 (7) Angular JS (15) article (10) Article Of The Day (13) Asp.Net (14) Azure (65) Azure DevOps (10) Azure Function (10) Azure IoT (7) C# (17) c-sharp corner (13) Career Advice (11) chart (11) CSharp (7) CSS (7) CSS3 (6) HighChart (10) How To (9) HTML5 (10) HTML5 Chart (11) Interview (6) IoT (11) Javascript (10) JQuery (82) jquery functions (9) JQWidgets (15) JQX Grid (17) Json (7) Microsoft (8) MVC (20) MVP (9) MXChip (7) News (18) Office 365 (7) Products (10) SQL (20) SQL Server (15) Visual Studio (10) Visual Studio 2017 (7) VS2017 (7) Web API (12) Windows 10 (7) Wordpress (9)
    • .NET
    • Achievements
    • ADO.NET
    • Android
    • Angular
    • Arduino
    • Article Of The Day
    • ASP.NET
    • Asp.Net Core
    • Automobile
    • Awards
    • Azure
    • Azure CDN
    • azure devops
    • Blockchain
    • Blog
    • Browser
    • C-Sharp Corner
    • C#
    • Career Advice
    • Code Snippets
    • CodeProject
    • Cognitive Services
    • Cosmos DB
    • CSS
    • CSS3
    • Data Factory
    • Database
    • Docker
    • Drawings
    • Drill Down Chart
    • English
    • Excel Programming
    • Exporting
    • Facebook
    • Fun
    • Gadgets
    • GitHub
    • GoPro
    • High Map
    • HighChart
    • How to
    • HTML
    • HTML5
    • Ignite UI
    • IIS
    • Interview
    • IoT
    • JavaScript
    • JQuery
    • jQuery UI
    • JQWidgets
    • JQX Grid
    • Json
    • Knockout JS
    • Linux
    • Machine Learning
    • Malayalam
    • Malayalam Poems
    • MDX Query
    • Microsoft
    • Microsoft ADOMD
    • Microsoft MVP
    • Microsoft Office
    • Microsoft Technologies
    • Microsoft Windows
    • Microsoft Windows Server
    • Mobile
    • MongoDB
    • Monthly Winners
    • MVC
    • MVC Grid
    • MySQL
    • News
    • Node JS
    • npm
    • Number Conversions
    • October 2015
    • Office 365
    • Office Development
    • One Plus
    • Outlook
    • Page
    • PHP
    • Poems
    • PowerShell
    • Products
    • Q&A
    • Raspberry PI
    • React
    • SEO
    • SharePoint
    • Skype
    • Social Media
    • Software
    • Spire.Doc
    • Spire.PDF
    • Spire.XLS
    • SQL
    • SQL Server
    • SSAS
    • SSMS
    • Storage In HTML5
    • Stories
    • Third Party Software Apps
    • Tips
    • Tools
    • Translator Text
    • Uncategorized
    • Unit Testing
    • UWP
    • VB.Net
    • Videos
    • Virtual Machine
    • Visual Studio
    • Visual Studio 2017
    • Wamp Server
    • Web API
    • Web Platform Installer
    • Webinars
    • WebMatrix
    • Windows 10
    • Windows 7
    • Windows 8.1
    • Wordpress
    • Writing

    ABOUT ME

    I am Sibeesh Venu, an engineer by profession and writer by passion. Microsoft MVP, Author, Speaker, Content Creator, Youtuber, Programmer. If you would like to know more about me, you can read my story here.

    Contact Me

    • info@sibeeshpassion.com

    Pages

    • About
    • Search
    • Privacy Policy
    • About
    • Search
    • Privacy Policy
    © Copyright Sibeesh Passion 2014-2025. All Rights Reserved.
    Go to mobile version