How to Load Data in the ListView Using C# and SQL Server

0
324

loadataListviewSQLFig.3

In this tutorial, I will teach you how to load data in the ListView using C# and SQL Server 2005. Displaying data in the ListView is a little bit the same with the DataGridView. The only difference is, you need to add items in displyaing data in the ListView, while in the DataGridView, you have to set the data source of it.

 

So, lets get started:

 

Create a database and name it “testdb”.

After creating database, do the following query for creating a table in the database that you have created.

 

Open Microsoft Visual Studio 2008 and create new Windows Form Application for C#. Then do the following design of a Form as shown below.

loadataListviewSQLFig.1

 

Go to the Solution Explorer, double click the “View Code”  to display the code editor.

loadataListviewSQLFig.2

 

In the code editor, declare all the classes that are needed.

Note: Put using System.Data.SqlClient; above the namespace to access sql server library.

 

After declaring the classes, go back to the design view double click the form and establish a connection between SQL server and C#.net.

After establishing the connection, go back to the design view double click the button and do the following codes for retrieving data in the database that will display in the ListView.

 

Output:

loadataListviewSQLFig.3

For all students who need programmer for your thesis system or anyone who needs a sourcecode in any programming languages. You can contact me @ :

 
Email – [email protected]
Mobile No. – 09305235027 – tnt

Facebook Comments

LEAVE A REPLY

Please enter your comment!
Please enter your name here