accounting software using vb visual basic, c#, and sql server



Benefits of Application Series of basic and sql server books
faq accounting software database programming
Benefits of Application Series of basic and sql server books

Displaying data in a DataGrid using Dataset and DataAdapter in a Visual Basic.Net Accounting Application



This article explains how to display data in a DataGrid using DataSet.

In this sample program, we will use the SQL Server database, FinAccounting and we will access Accounts table of FinAccounting database and display records in the datagrid control.

Preparation:

Create a Windows form and add a DataGrid control to the form.

Tasks:




Declare and setup the Connection string

This task declares, instantiates and sets up the connection. We need a connection when we want to access a data source. We will use a connection string to set up the connection with the database. We have used the SqlConnection class which is only to be used with MS SQL Server database. It has been specially optimized for connecting to the SQL Server database.

Declare and build a query string



All query statements used in the program are declared in this section and assigned to string variables.

Create SqlDataAdapter Object



The DataAdapter is used for retrieving data from the database and populating the dataset. The DataAdapter is the connector class that sits between the disconnected and the connected parts of ADO.Net. The DataAdapter class is instantiated using the New constructor, which is overloaded. If we use the default constructor for the DataAdapter, we need to specify the Command object for the actions performed. This means that if we want to retrieve rows from the Data Source, we will have to set the Select command property.

Create a DataSet Object and Fill it with Accounts data



Unlike the managed provider objects, the DataSet object do not diverge between the OleDb and SqlClient .net namespaces. We declare a DataSet object the same way regardless of which .NET data provider we are using:

myAccDataset = New DataSet()

Once we have set up the DataAdapter and the DataSet, we need to populate the DataSet. The Fill method of the DataAdapter class is used for populating and refreshing the DataSet object.

Attach DataSet to DataGrid



Now we use DataSource method of DataGrid to attached the DataSet data to the data grid.

Program Code


The DataViewManager returned by the DefaultViewManager property allows us to create custom settings for each DataTable in the DataSet.

Summary:



This program demonstrates how to access data using a DataAdapter and store it in a dataset. This DataSet is attached to the datagrid and displayed on the form.

Free Resources

SITEMAP  |   About VKINFOTEK  |   Accounting Software Client Server  |   Accounting Software Visual Basic.Net Sql Server  |   Inventory Software using Visual Basic  |   Accounting Software using ASP.Net and SQLServer  |   Client Server Programming  |   Complete Programmer  |   Testimonials  |   Data  |   Object  |   Middle Tier  |   Data Binding  |   Simple Data Binding  |   IT Related NEWS  |   Love and Links  |   State Management (Web Development)  |   Adodotnet Evolution  |   AJAX  |   Visual Basic 2005 Strings  |   Accounting Software  |   Implementing Constructors in Visual Basic.Net  |   Implementing Structure in Visual Basic.Net  |   Creating, Using Namespaces in Visual Basic.Net  |   What is an Assembly ?  |   How to create a Shared Assembly ?  |   Accounting Info Africa  |   About Us  |   Resume Format  |   Add to Delicious  |   Digg This !!  |   Technorati Profile
Copyright. 2001-2006.
VK Infotek Inc.
Updated on
Valid XHTML Page