0% found this document useful (0 votes)
4 views1 page

Visualize Product Stock with Charting

This code is creating a bar chart in a Windows Form that displays the number of units in stock for each product using data from a SQL database. It imports required libraries, connects to the database, runs a SQL query to retrieve product names and unit counts, loads the data into a dataset, creates a bar chart control, sets the data source of the chart to the dataset table, and configures the chart series to use the product names and unit counts from the data.

Uploaded by

Nouredine Fred
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Visualize Product Stock with Charting

This code is creating a bar chart in a Windows Form that displays the number of units in stock for each product using data from a SQL database. It imports required libraries, connects to the database, runs a SQL query to retrieve product names and unit counts, loads the data into a dataset, creates a bar chart control, sets the data source of the chart to the dataset table, and configures the chart series to use the product names and unit counts from the data.

Uploaded by

Nouredine Fred
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Imports System.

Data
Imports [Link]
Imports [Link]
'Import Required Libraries

Public Class Form2

Private Sub Form2_Load(sender As Object, e As EventArgs) Handles [Link]

Dim strConn As String = "Data Source=DELL-PC;Initial Catalog=gestion A;Integrated


Security=True"

Dim conn As New SqlConnection(strConn)

Dim sqlProducts As String = "SELECT ProductName, UnitsInStock FROM Products"


Dim da As New SqlDataAdapter(sqlProducts, conn)
Dim ds As New DataSet()
[Link](ds, "Products")

Dim ChartArea1 As ChartArea = New ChartArea()


Dim Legend1 As Legend = New Legend()
Dim Series1 As Series = New Series()
Dim Chart1 = New Chart()
[Link](Chart1)

[Link] = "ChartArea1"
[Link](ChartArea1)
[Link] = "Legend1"
[Link](Legend1)
[Link] = New [Link](13, 13)
[Link] = "Chart1"
[Link] = "ChartArea1"
[Link] = "Legend1"
[Link] = "Series1"
[Link](Series1)
[Link] = New [Link](800, 400)
[Link] = 0
[Link] = "Chart1"

[Link]("Series1").XValueMember = "ProductName"
[Link]("Series1").YValueMembers = "UnitsInStock"

[Link] = [Link]("Products")
End Sub
End Class

You might also like