to forespørgsler til dette program
Hej.Følgende kode bruger jeg til at vise noget grafisk statistik fra data i en oracle DB....
Hvordan gør jeg hvis jeg også vil have data med fra en anden forespørgsel..???
kode:
Imports System.Data.OracleClient
Imports Dundas.Charting.WinControl
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TabControl1 As System.Windows.Forms.TabControl
Friend WithEvents TabPage1 As System.Windows.Forms.TabPage
Friend WithEvents TabPage2 As System.Windows.Forms.TabPage
Friend WithEvents TabPage3 As System.Windows.Forms.TabPage
Friend WithEvents OleDbDataAdapter1 As System.Data.OleDb.OleDbDataAdapter
Friend WithEvents OleDbConnection1 As System.Data.OleDb.OleDbConnection
Friend WithEvents OleDbSelectCommand1 As System.Data.OleDb.OleDbCommand
Friend WithEvents Chart1 As Dundas.Charting.WinControl.Chart
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim ChartArea1 As Dundas.Charting.WinControl.ChartArea = New Dundas.Charting.WinControl.ChartArea
Dim Legend1 As Dundas.Charting.WinControl.Legend = New Dundas.Charting.WinControl.Legend
Dim Series1 As Dundas.Charting.WinControl.Series = New Dundas.Charting.WinControl.Series
Dim Series2 As Dundas.Charting.WinControl.Series = New Dundas.Charting.WinControl.Series
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.TabControl1 = New System.Windows.Forms.TabControl
Me.TabPage1 = New System.Windows.Forms.TabPage
Me.Chart1 = New Dundas.Charting.WinControl.Chart
Me.TabPage2 = New System.Windows.Forms.TabPage
Me.DataGrid1 = New System.Windows.Forms.DataGrid
Me.TabPage3 = New System.Windows.Forms.TabPage
Me.OleDbDataAdapter1 = New System.Data.OleDb.OleDbDataAdapter
Me.OleDbSelectCommand1 = New System.Data.OleDb.OleDbCommand
Me.OleDbConnection1 = New System.Data.OleDb.OleDbConnection
Me.TabControl1.SuspendLayout()
Me.TabPage1.SuspendLayout()
CType(Me.Chart1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.TabPage2.SuspendLayout()
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'TabControl1
'
Me.TabControl1.Controls.Add(Me.TabPage1)
Me.TabControl1.Controls.Add(Me.TabPage2)
Me.TabControl1.Controls.Add(Me.TabPage3)
Me.TabControl1.Dock = System.Windows.Forms.DockStyle.Top
Me.TabControl1.Location = New System.Drawing.Point(0, 0)
Me.TabControl1.Name = "TabControl1"
Me.TabControl1.SelectedIndex = 0
Me.TabControl1.Size = New System.Drawing.Size(1016, 736)
Me.TabControl1.TabIndex = 55
'
'TabPage1
'
Me.TabPage1.BackColor = System.Drawing.SystemColors.Window
Me.TabPage1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.TabPage1.Controls.Add(Me.Chart1)
Me.TabPage1.Location = New System.Drawing.Point(4, 22)
Me.TabPage1.Name = "TabPage1"
Me.TabPage1.Size = New System.Drawing.Size(1008, 710)
Me.TabPage1.TabIndex = 0
Me.TabPage1.Text = "Forsikringer"
'
'Chart1
'
Me.Chart1.BackColor = System.Drawing.Color.DarkOrange
Me.Chart1.BackGradientEndColor = System.Drawing.Color.White
Me.Chart1.BackGradientType = Dundas.Charting.WinControl.GradientType.TopBottom
Me.Chart1.BorderLineColor = System.Drawing.Color.Black
Me.Chart1.BorderLineWidth = 2
Me.Chart1.BorderSkin.FrameBackColor = System.Drawing.Color.SandyBrown
Me.Chart1.BorderSkin.FrameBackGradientEndColor = System.Drawing.Color.Chocolate
Me.Chart1.BorderSkin.PageColor = System.Drawing.Color.AliceBlue
ChartArea1.Area3DStyle.Light = Dundas.Charting.WinControl.LightStyle.Realistic
ChartArea1.AxisX.Interval = 1
ChartArea1.AxisX.IntervalOffsetType = Dundas.Charting.WinControl.DateTimeIntervalType.Days
ChartArea1.AxisX.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Days
ChartArea1.AxisX.LabelsAutoFit = False
ChartArea1.AxisX.LabelStyle.FontAngle = 90
ChartArea1.AxisX.LabelStyle.Format = "M"
ChartArea1.AxisX.LineColor = System.Drawing.Color.FromArgb(CType(120, Byte), CType(64, Byte), CType(64, Byte), CType(64, Byte))
ChartArea1.AxisX.MajorGrid.LineColor = System.Drawing.Color.FromArgb(CType(120, Byte), CType(64, Byte), CType(64, Byte), CType(64, Byte))
ChartArea1.AxisX.MajorTickMark.Style = Dundas.Charting.WinControl.TickMarkStyle.Inside
ChartArea1.AxisX.Title = "Dato"
ChartArea1.AxisX2.Interval = 1
ChartArea1.AxisX2.IntervalType = Dundas.Charting.WinControl.DateTimeIntervalType.Days
ChartArea1.AxisX2.LineColor = System.Drawing.Color.FromArgb(CType(120, Byte), CType(64, Byte), CType(64, Byte), CType(64, Byte))
ChartArea1.AxisY.LabelStyle.Format = "P1"
ChartArea1.AxisY.LineColor = System.Drawing.Color.FromArgb(CType(120, Byte), CType(64, Byte), CType(64, Byte), CType(64, Byte))
ChartArea1.AxisY.MajorGrid.LineColor = System.Drawing.Color.FromArgb(CType(120, Byte), CType(64, Byte), CType(64, Byte), CType(64, Byte))
ChartArea1.AxisY.Title = "Hitrate%"
ChartArea1.AxisY2.LineColor = System.Drawing.Color.FromArgb(CType(120, Byte), CType(64, Byte), CType(64, Byte), CType(64, Byte))
ChartArea1.BackColor = System.Drawing.Color.DarkOrange
ChartArea1.BackGradientEndColor = System.Drawing.Color.White
ChartArea1.BackGradientType = Dundas.Charting.WinControl.GradientType.TopBottom
ChartArea1.BorderColor = System.Drawing.Color.Empty
ChartArea1.BorderStyle = Dundas.Charting.WinControl.ChartDashStyle.Solid
ChartArea1.Name = "Default"
Me.Chart1.ChartAreas.Add(ChartArea1)
Me.Chart1.Dock = System.Windows.Forms.DockStyle.Top
Legend1.Alignment = System.Drawing.StringAlignment.Center
Legend1.BackColor = System.Drawing.Color.Transparent
Legend1.BorderColor = System.Drawing.Color.Transparent
Legend1.Docking = Dundas.Charting.WinControl.LegendDocking.Top
Legend1.LegendStyle = Dundas.Charting.WinControl.LegendStyle.Row
Legend1.Name = "Default"
Me.Chart1.Legends.Add(Legend1)
Me.Chart1.Location = New System.Drawing.Point(0, 0)
Me.Chart1.Name = "Chart1"
Me.Chart1.Palette = Dundas.Charting.WinControl.ChartColorPalette.Pastel
Series1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.0!)
Series1.Name = "Series3"
Series2.ChartType = "Spline"
Series2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.0!)
Series2.Name = "Series2"
Me.Chart1.Series.Add(Series1)
Me.Chart1.Series.Add(Series2)
Me.Chart1.Size = New System.Drawing.Size(1004, 312)
Me.Chart1.TabIndex = 1
'
'TabPage2
'
Me.TabPage2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.TabPage2.Controls.Add(Me.DataGrid1)
Me.TabPage2.Location = New System.Drawing.Point(4, 22)
Me.TabPage2.Name = "TabPage2"
Me.TabPage2.Size = New System.Drawing.Size(1008, 710)
Me.TabPage2.TabIndex = 1
Me.TabPage2.Text = "ServiceAbonnementer"
'
'DataGrid1
'
Me.DataGrid1.DataMember = ""
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location = New System.Drawing.Point(16, 16)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.Size = New System.Drawing.Size(968, 624)
Me.DataGrid1.TabIndex = 0
'
'TabPage3
'
Me.TabPage3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.TabPage3.Location = New System.Drawing.Point(4, 22)
Me.TabPage3.Name = "TabPage3"
Me.TabPage3.Size = New System.Drawing.Size(1008, 710)
Me.TabPage3.TabIndex = 2
Me.TabPage3.Text = "MobilAbonnementer"
'
'OleDbDataAdapter1
'
Me.OleDbDataAdapter1.SelectCommand = Me.OleDbSelectCommand1
Me.OleDbDataAdapter1.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "HITRATE_DK", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("NAVN", "NAVN"), New System.Data.Common.DataColumnMapping("PRODUKTER", "PRODUKTER"), New System.Data.Common.DataColumnMapping("LISTEN", "LISTEN"), New System.Data.Common.DataColumnMapping("POINTS", "POINTS"), New System.Data.Common.DataColumnMapping("LONNR", "LONNR"), New System.Data.Common.DataColumnMapping("ABON", "ABON"), New System.Data.Common.DataColumnMapping("READYSALDO", "READYSALDO"), New System.Data.Common.DataColumnMapping("READYPROCENT", "READYPROCENT"), New System.Data.Common.DataColumnMapping("BESVARELSE", "BESVARELSE"), New System.Data.Common.DataColumnMapping("TOTALPOINTS", "TOTALPOINTS"), New System.Data.Common.DataColumnMapping("REG", "REG"), New System.Data.Common.DataColumnMapping("POT", "POT"), New System.Data.Common.DataColumnMapping("HITRATE", "HITRATE"), New System.Data.Common.DataColumnMapping("LASTUPDATE", "LASTUPDATE"), New System.Data.Common.DataColumnMapping("DATO", "DATO"), New System.Data.Common.DataColumnMapping("KALD", "KALD"), New System.Data.Common.DataColumnMapping("AVGPRODUKTPOINT", "AVGPRODUKTPOINT"), New System.Data.Common.DataColumnMapping("FORSABON", "FORSABON"), New System.Data.Common.DataColumnMapping("SERVABON", "SERVABON"), New System.Data.Common.DataColumnMapping("ALARMABON", "ALARMABON"), New System.Data.Common.DataColumnMapping("TELEABON", "TELEABON")})})
'
'OleDbSelectCommand1
'
Me.OleDbSelectCommand1.CommandText = "SELECT NAVN, PRODUKTER, LISTEN, POINTS, LONNR, ABON, READYSALDO, READYPROCENT, BE" & _
"SVARELSE, TOTALPOINTS, REG, POT, HITRATE, LASTUPDATE, DATO, KALD, AVGPRODUKTPOIN" & _
"T, FORSABON, SERVABON, ALARMABON, TELEABON FROM HITRATE_DK"
Me.OleDbSelectCommand1.Connection = Me.OleDbConnection1
'
'OleDbConnection1
'
Me.OleDbConnection1.ConnectionString = "Provider=""MSDAORA.1"";User ID=intranet_test;Data Source=ora02;persist security inf" & _
"o=False"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.SystemColors.Window
Me.ClientSize = New System.Drawing.Size(1016, 734)
Me.Controls.Add(Me.TabControl1)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Form1"
Me.TabControl1.ResumeLayout(False)
Me.TabPage1.ResumeLayout(False)
CType(Me.Chart1, System.ComponentModel.ISupportInitialize).EndInit()
Me.TabPage2.ResumeLayout(False)
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim oraConn As OracleConnection
Dim selectQuery As String
Dim da As OracleDataAdapter
Dim ds As DataSet
Dim cmd As New OracleCommand
'create new oracle connection
oraConn = New OracleConnection("user id = intranet_drift;password = intranet_drift_psw;data source = ora01")
'oraConn = New OracleConnection("user id = intranet_test;password = intranet_test_psw;data source = ora02")
selectQuery = "SELECT * FROM hitrate_dk where navn = 'MSA' and substr(dato,4,2) = '11' order by dato"
cmd.CommandType = CommandType.Text
cmd.CommandText = selectQuery
cmd.Connection = oraConn
da = New OracleDataAdapter(cmd)
ds = New DataSet
Try
'open oracle connection
oraConn.Open()
'Fill dataset with PRODUCTS table
da.Fill(ds, "hitrate_dk")
'Bind dataset to datagrid
DataGrid1.DataSource = ds.Tables(0)
DataGrid1.Show()
' set chart data source
Chart1.DataSource = ds
' set series members names for the X and Y values
Chart1.Series("Series3").ValueMemberX = "Dato"
Chart1.Series("Series3").ValueMembersY = "Hitrate"
Chart1.Series("Series2").ValueMembersY = "realhit"
' data bind to the selected data source
Chart1.DataBind()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class
