Steps involved to fill a dataset, DOT NET Programming

Assignment Help:

What are the steps involved to fill a dataset ?

The sample code is shown below:

Private Sub LoadData()

Dim strConnectionString As String

strConnectionString = AppSettings.Item("ConnectionString") Dim objConn As New SqlConnection(strConnectionString) objConn.Open()

Dim objCommand As New SqlCommand("Select FirstName from

Employees")

objCommand.Connection = objConn

Dim objDataAdapter As New SqlDataAdapter() objDataAdapter.SelectCommand = objCommand Dim objDataSet As New DataSet

End Sub

In this type of questions interviewer is looking from the practical angle, that have you worked with dataset & datadapters. Let me try to explain the above code first and then we go to what steps must be told during the interview.

Dim objConn As New SqlConnection(strConnectionString)

objConn.Open()

The First step is to open the connection. Now again note the connection string is loaded from the config file.

Dim objCommand As New SqlCommand("Select FirstName from Employees") objCommand.Connection = objConn

The Second step is to create a command object with the appropriate SQL and set the connection object to this command

Dim objDataAdapter As New SqlDataAdapter()

objDataAdapter.SelectCommand = objCommand

The Third steps is to create an  Adapter object and pass the command object to the adapter object.

objDataAdapter.Fill(objDataSet)

The Fourth step is to load the dataset using the "Fill" method of the dataadapter.

lstData.DataSource = objDataSet.Tables(0).DefaultView

lstData.DisplayMember = "FirstName"

lstData.ValueMember = "FirstName"

The Fifth step is to bind to the loaded dataset with the GUI. At that moment the sample has a listbox as the UI. The Binding of the UI is completed by using the DefaultView of the dataset. Just to revise each dataset has tables and each table has views. In this sample we have only loaded one table that is Employees table so we are referring that with an index of zero.


Related Discussions:- Steps involved to fill a dataset

In what order do the events of an aspx page execute, In what order do the e...

In what order do the events of an ASPX page execute. As a developer is it important to understand these events?   If you try to access it in Page_Load that is way previous than

Develop a project using microsoft active directory, Net project Project ...

Net project Project Description: We want to make .net project Microsoft Active Directory, PMS Lync 2010 - 2013 databases creating a license key for their SW generati

What is asp.net authentication providers and iis security, What is ASP.NET ...

What is ASP.NET Authentication Providers and IIS Security? ASP.NET executes authentication using authentication providers, which are code modules that determine credentials and

Virtual webcam effects and sourcecode, Virtual Webcam effects + Sourcecode ...

Virtual Webcam effects + Sourcecode + Setup + Nice User Interface Project Description: i want a similar webcam effects application which can apply effects to webcam feed. So

Setup project with database, i am working on an project and my client needs...

i am working on an project and my client needs it in 2 days.project is ready but don''t know how to make setup project including local sql database(.mdf) included in setup..

Perform arithmetic operation on floating values in c#, Perform Arithmetic o...

Perform Arithmetic operations on Floating Values - C# Program Hello, I've been trying so many codes for this but those codes didn't work well. Please write the code for Perfor

Explain memory-mapped files, Explain memory-mapped files. Memory-mapped...

Explain memory-mapped files. Memory-mapped files (MMFs) permit you map the content of a file to the logical address of an application. These files enable the multiple processes

Program of nested loop - c# program, Program of Nested Loop - C# Program ...

Program of Nested Loop - C# Program I am a learner of C# language and i am struggling with the Loops in c#. Can you have any code examples for this.

Want to generate random numbers, want to generate random numbers between 1...

want to generate random numbers between 1-15 and no one should repeat until all numbers have come once....

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd