Hi All
I have 2 forms. The first is a dashboard and the second is a specific form Technical Analysis. I did all my playing around on the dashboard form. I copied the form panels which contain charts and bits to the second form and also the code for one of graphs. On the dashboard the graph works, but on the second it comes up with exception error. The second form has different names for graph, panel etc.. so i dont see why it doesnt work. Any ideas?
Working version on Dashboard:
Non-working version on Techncal Analysis form:Code:'The Excel file name Dim fileNameString As String = "D:\userdata\thorley\Cell switch off\AR\ASB\DB\NetAct_Data1.xlsx" 'connection string for Xlsx files - Microsoft ACE OLEDB 12.0 'Connect to Excel 2007 (and later) files with the Xlsx file extension. 'That is the Office Open XML format with macros disabled. ' "HDR=Yes;" indicates that the first row contains columnnames, not data. '"HDR=No;" indicates the opposite. Dim sConn As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileNameString + ";Extended Properties=""Excel 12.0 Xml;HDR=YES""" Dim myConnection As New OleDbConnection(sConn) myConnection.Open() ' The code to follow uses a SQL SELECT command to display the data from the worksheet. ' Create new OleDbCommand to return data from worksheet. ' change range Dim myCommand As New OleDbCommand("Select * From [Delay$h1:u601]", myConnection) ' create a database reader Dim myReader As OleDbDataReader = myCommand.ExecuteReader '(CommandBehavior.CloseConnection) ' Populate the chart with data in the file ' can also use Chart.DataBindTable DashTopLeftGraph.Series(1).Points.DataBindXY(myReader, "Time seconds", myReader, "Major%") myReader.Close() Dim myReader1 As OleDbDataReader = myCommand.ExecuteReader '(CommandBehavior.CloseConnection) DashTopLeftGraph.Series(2).Points.DataBindXY(myReader1, "Time seconds", myReader1, "Minor%") myReader1.Close() Dim myReader2 As OleDbDataReader = myCommand.ExecuteReader '(CommandBehavior.CloseConnection) DashTopLeftGraph.Series(0).Points.DataBindXY(myReader2, "Time seconds", myReader2, "Critical%") myReader1.Close() ' close the reader and the connection 'myReader.Close() myConnection.Close() DashTopLeftGraph.ChartAreas("DashTopLeftGraph").AxisX.Title = "Time Secs" DashTopLeftGraph.ChartAreas("DashTopLeftGraph").AxisY.Title = "%" DashTopLeftGraph.ChartAreas("DashTopLeftGraph").AxisY.Maximum = 100
Error comes at
"TechAnalTopLeftGraph.Series(1).Points.DataBindXY(myReader, "Time seconds", myReader, "Major%")"
Code:If Int(ASB_Tech_Anal_Inf_Delay_Time.Text) > 0 Then Else MsgBox("Check Delay Time Entry!", vbOK, "ASB Entry Error") GoTo Jumpover End If 'The Excel file name Dim fileNameString As String = "D:\userdata\thorley\Cell switch off\AR\ASB\DB\NetAct_Data1.xlsx" 'connection string for Xlsx files - Microsoft ACE OLEDB 12.0 'Connect to Excel 2007 (and later) files with the Xlsx file extension. 'That is the Office Open XML format with macros disabled. ' "HDR=Yes;" indicates that the first row contains columnnames, not data. '"HDR=No;" indicates the opposite. Dim sConn As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileNameString + ";Extended Properties=""Excel 12.0 Xml;HDR=YES""" Dim myConnection As New OleDbConnection(sConn) myConnection.Open() ' The code to follow uses a SQL SELECT command to display the data from the worksheet. ' Create new OleDbCommand to return data from worksheet. ' change range Dim myCommand As New OleDbCommand("Select * From [Delay$h1:u601]", myConnection) ' create a database reader Dim myReader As OleDbDataReader = myCommand.ExecuteReader '(CommandBehavior.CloseConnection) ' Populate the chart with data in the file ' can also use Chart.DataBindTable TechAnalTopLeftGraph.Series(1).Points.DataBindXY(myReader, "Time seconds", myReader, "Major%") myReader.Close() Dim myReader1 As OleDbDataReader = myCommand.ExecuteReader '(CommandBehavior.CloseConnection) TechAnalTopLeftGraph.Series(2).Points.DataBindXY(myReader1, "Time seconds", myReader1, "Minor%") myReader1.Close() Dim myReader2 As OleDbDataReader = myCommand.ExecuteReader '(CommandBehavior.CloseConnection) TechAnalTopLeftGraph.Series(0).Points.DataBindXY(myReader2, "Time seconds", myReader2, "Critical%") myReader1.Close() ' close the reader and the connection 'myReader.Close() myConnection.Close() TechAnalTopLeftGraph.ChartAreas("TechAnalTopLeftGraph").AxisX.Title = "Time Secs" TechAnalTopLeftGraph.ChartAreas("TechAnalTopLeftGraph").AxisY.Title = "%" TechAnalTopLeftGraph.ChartAreas("TechAnalTopLeftGraph").AxisY.Maximum = 100 jumpover:
Any help welcomed. I hope its something silly




Reply With Quote
