therayster
MIS
I'm writing an app to parse a device log file and insert the data into a database. As it processes new rows from the device I'd like to simply display them on screen in a datagrid. At first i was trying to build the grid on the fly, but everything seemed to say that it would be easier to build a datatable, so I went that route. Which leads me to:
[tt]
Dim sourceTbl As New DataTable 'Creating DataTable, sourceTbl
sourceTbl.Columns.Add("TblCol1") 'Adding columns to the table
sourceTbl.Columns.Add("TblCol2")
sourceTbl.Columns.Add("TblCol3")
sourceTbl.Columns.Add("TblCol4")
sourceTbl.Columns.Add("TblCol5")
sourceTbl.Columns.Add("TblCol6")
sourceTbl.Columns.Add("TblCol7")
sourceTbl.Columns.Add("TblCol8")
sourceTbl.Columns.Add("TblCol9")
sourceTbl.Columns.Add("TblCol10")
sourceTbl.Columns.Add("TblCol11")
sourceTbl.Columns.Add("TblCol12")
sourceTbl.Columns.Add("TblCol13")
sourceTbl.Columns.Add("TblCol14")
ixx = 1
Dim displayLog = System.IO.File.ReadAllLines("C:\KipLogs\KipLog.csv") 'This reads the combined output file into the displayLog array
For Each iii In displayLog 'And this loop goes through the array line by line
charge = Split(iii, ",") 'charge is an array made from the current line of the logfile being split into chunks
sourceTbl.Rows.Add(charge()) 'Here we should be adding a row to the DataTable sourceTbl
Me.ToolStripStatusLabel1.Text = "Now processing KipLog line " & ixx & " of " & ix
Me.TextBox1.AppendText(iii & vbCrLf) 'Writing the current line of the logfile to the screen for testing purposes
Me.TextBox1.Refresh()
ixx = ixx + 1
Next
[/tt]
First off, I'm getting an error "RankException was unhandled:Attempted to operate on an array with the incorrect number of dimensions." Which I absolutely don't get since the array has 14 members (0-13) and I've obviously got 14 columns. And I've added and removed columns and get the same error.
[tt]
Dim sourceTbl As New DataTable 'Creating DataTable, sourceTbl
sourceTbl.Columns.Add("TblCol1") 'Adding columns to the table
sourceTbl.Columns.Add("TblCol2")
sourceTbl.Columns.Add("TblCol3")
sourceTbl.Columns.Add("TblCol4")
sourceTbl.Columns.Add("TblCol5")
sourceTbl.Columns.Add("TblCol6")
sourceTbl.Columns.Add("TblCol7")
sourceTbl.Columns.Add("TblCol8")
sourceTbl.Columns.Add("TblCol9")
sourceTbl.Columns.Add("TblCol10")
sourceTbl.Columns.Add("TblCol11")
sourceTbl.Columns.Add("TblCol12")
sourceTbl.Columns.Add("TblCol13")
sourceTbl.Columns.Add("TblCol14")
ixx = 1
Dim displayLog = System.IO.File.ReadAllLines("C:\KipLogs\KipLog.csv") 'This reads the combined output file into the displayLog array
For Each iii In displayLog 'And this loop goes through the array line by line
charge = Split(iii, ",") 'charge is an array made from the current line of the logfile being split into chunks
sourceTbl.Rows.Add(charge()) 'Here we should be adding a row to the DataTable sourceTbl
Me.ToolStripStatusLabel1.Text = "Now processing KipLog line " & ixx & " of " & ix
Me.TextBox1.AppendText(iii & vbCrLf) 'Writing the current line of the logfile to the screen for testing purposes
Me.TextBox1.Refresh()
ixx = ixx + 1
Next
[/tt]
First off, I'm getting an error "RankException was unhandled:Attempted to operate on an array with the incorrect number of dimensions." Which I absolutely don't get since the array has 14 members (0-13) and I've obviously got 14 columns. And I've added and removed columns and get the same error.