Steps involved to fill a dataset, DOT NET Programming

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.

Posted Date: 9/24/2012 2:46:32 AM | Location : United States







Related Discussions:- Steps involved to fill a dataset, Assignment Help, Ask Question on Steps involved to fill a dataset, Get Answer, Expert's Help, Steps involved to fill a dataset Discussions

Write discussion on Steps involved to fill a dataset
Your posts are moderated
Related Questions
Looking for web designer Project Description: I am seeking website designer with developing skills of Html, .Net and also supports in all browsers. Please ping your previous

Can you give an overview of ADO.NET architecture? The most important part  in the ADO.NET architecture is the "Data Provider". The  Data Provider provides access to the datasou

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. This class autom

Inventory billing and Management application in .net Project Description: Digital Inventory management Main Features         Multi user User friendly windows based s

What is a Metadata?  Metadata is information about a PE. In COM, metadata is communicated through non-standardized type libraries. In .NET, this data is contained in the header

Printing Triangles - C# Program I need program code for Printing Triangles in C#. Can anybody send me there ideas?

What are value types and reference types?  Value type - bool, byte, chat, decimal, double, enum , float, int, long, sbyte, short, strut, uint, ulong, ushort. Value types are

What are the various ways of authentication techniques in ASP.NET? The Selection of  an authentication provider is as simple as making an entry in  the web.config file of  the

What is DBCC? The Database Consistency Checker Commands (DBCC) is used to check the logical and physical consistency of the database structure.The DBCC statements can fix and d

Project Description: hi i need to develop a software scrapebox exect same with all Skills required: .NET, Java, C# Programming, Visual Basic, Visual Basic for Apps