Creating a Chart using Data from a Database with MS Chart Control
(Page 1 of 4 )
We have seen earlier how to bring in a Microsoft Chart Control to a VB 6 project and configure some of its properties. The data displayed by the chart was hard-coded. In real life scenarios, the data will be generated by a program and the format of the output must be fed to the chart programmatically. Again this is one of the frequently asked popular questions on many forums: how do you use the MS Chart Control with data retrieved from a database?
Introduction
This tutorial shows you step-by-step how you may use the Microsoft Chart Control with data retrieved from a database, explaining the logic used. The data is retrieved by a suitable query run against a database on the localhost, XPHTEK, a SQL 2000 Server. The VB6 program and the SQL Server are both running on a Windows XP Professional machine.
Retrieving data from a database
Using ADO objects and a suitable connection string, the data will be retrieved from the database. The chart will be using the data from the SQL 2000 Server and therefore the SQL Server must be running.
Database details
The details of a simple table called 'Products' on the TestWiz database will be used. The next picture shows the database, 'TestWiz' on the left, the table in the tables list on the right and all the data it contains at the bottom. It has four rows of data on six columns.

Next: Visual Basic Project to retrieve data >>
More Code Examples Articles
More By Jayaram Krishnaswamy