Jump to content
Whiteangel

Chart - ligacao a base de dados

Recommended Posts

Whiteangel

Boas pessoal,

Eu quero que o meu chart me mostre dois campos de uma tabela, mas não estou a conseguir programa-lo, estou a fazer assim

Const cs As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Acer\Documents\Visual Studio 2010\Projects\Empresa2\Empresa2Teste.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"

Dim con As New SqlConnection(cs)

con.Open()

Dim novonome, novaquantidade As String

Dim sql As String = "SELECT * FROM Artigod WHERE Nome='" & novonome & "', " & "Quantidade='" & novaquantidade & "'"

Dim sqlcom As New SqlCommand(sql, con)

Dim da As New OleDbDataAdapter(sql, con) <-- da erro de que o tipo nao esta definido

Dim ds As New DataSet()

da.Fill(ds, "Artigos")

Dim ChartArea1 As ChartArea = New ChartArea() <-- da erro de que o tipo nao esta definido

Dim Legend1 As Legend = New Legend() <-- da erro de que o tipo nao esta definido

Dim Series1 As Series = New Series() <-- da erro de que o tipo nao esta definido

Dim Chart1 = New DataVisualization.Charting.Chart()

Me.Controls.Add(Chart1)

ChartArea1.Name = "ChartArea1"

Chart1.ChartAreas.Add(ChartArea1)

Legend1.Name = "Legend1"

Chart1.Legends.Add(Legend1)

Chart1.Location = New System.Drawing.Point(50, 50)

Chart1.Name = "Chart1"

Series1.ChartArea = "ChartArea1"

Series1.Legend = "Legend1"

Series1.Name = "Series1"

Chart1.Series.Add(Series1)

Chart1.Size = New System.Drawing.Size(750, 500)

Chart1.TabIndex = 0

Chart1.Text = "Chart1"

Chart1.Series("Series1").XValueMember = "Nome"

Chart1.Series("Series1").YValueMembers = "Quantidade"

Chart1.DataSource = ds.Tables("Artigos")

con.Close()

Edited by Whiteangel

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.