tommyready
Member
- Joined
- Jul 1, 2009
- Messages
- 23
- Programming Experience
- 3-5
I have a windows form that querys a database and loads the data into a chart. It worked fine for awhile then it literally stopped showing my form when I hit "Run"
Here is my code:
Here is my code:
VB.NET:
Public Class Form1
Private rsTaskCount As ADODB.Recordset
Private cn As ADODB.Connection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cn = New ADODB.Connection
mfDataChart.ToDefaults()
' Establish the connection using the connection string.
cn.ConnectionString = "Provider=SQLOLEDB.1;Password=xxxxxx;" & _
"Persist Security Info=True; User ID=reports;" & _
"Initial Catalog=Scan; Data Source=xx.xx.xx.xx"
' Open the connection.
cn.Open()
Dim strQuery As String ' SQL query string.
strQuery = "SELECT * FROM vwTaskByEmployeePerMonth"
rsTaskCount = New ADODB.Recordset
' Open the recordset.
rsTaskCount.CursorLocation = ADODB.CursorLocationEnum.adUseClient
rsTaskCount.Open(strQuery, cn, ADODB.CursorTypeEnum.adOpenKeyset)
Dim chrtarr(0 To rsTaskCount.RecordCount, 0 To 3)
mfDataChart.ShowLegend = True
mfDataChart.chartType = MSChart20Lib.VtChChartType.VtChChartType2dArea
'relate array to the recordset returned
For X = 0 To rsTaskCount.RecordCount
chrtarr(X, 1) = rsTaskCount("Employee")
chrtarr(X, 2) = rsTaskCount("TaskCount")
chrtarr(X, 3) = rsTaskCount("EndDate")
rsTaskCount.MoveNext()
Next X
'feed chart from this array
With mfDataChart
.ChartData = chrtarr
'only the three columns, 2,3 4 will provide data
.ColumnCount = 2
.ColumnLabelCount = 1
.Column = 1
End With
MsgBox(rsTaskCount.RecordCount)
End Sub
End Class