Hi, Im coding a small report parsing utility for one of my colleagues. It imports an excel spreadsheet, and populates a DataSet, which then is bound to a DataView, which in turn bound to a DataGrid. I then check some flags, and concatenate a string into a newly-made column (the one Im having trouble sorting). The problem I'm having is why I try to sort by the new column, a couple of rows are out of place, while all the rest are properly ordered. Since sorting is a 1-liner, I dont even know how to go about debugging it. Any thoughts?
(...)
MyConnection = New System.Data.OleDb.OleDbConnection( _
"provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source=C:\Imitation Desktop\Parser_VB\Proj.xls; " & _
"Extended Properties=Excel 8.0;")
' Select the data from Sheet1 of the workbook.
MyCommand = New System.Data.OleDb.OleDbDataAdapter( _
"SELECT L_Region, P_Site, UserName, CompName, MSProject2000, MSProject2002, MSProject2003 from [Sheet1$]", MyConnection)
DS = New System.Data.DataSet()
MyCommand.Fill(DS)
MyConnection.Close()
'Dispose OLE controls
MyConnection.Dispose()
MyCommand.Dispose()
(...)
DS.Tables(0).Columns().Add("Versions", System.Type.GetType("System.String"))
(...)
ForEach row As DataRowView In dvView
row.Item("Versions") = ""
'Check flags to see if this version exists
If (alVers.Item(i).MS2000 = 1) Then
row.Item("Versions") = "MS Project 2000"
EndIf
If (alVers.Item(i).MS2002 = 1) Then
If (row.Item("Versions") = "") Then
row.Item("Versions") = "MS Project 2002"
Else
row.Item("Versions") = String.Concat(row.Item("Versions"), ", MS Project 2002")
EndIf
EndIf
If (alVers.Item(i).MS2003 = 1) Then
If (row.Item("Versions") = "") Then
row.Item("Versions") = "MS Project 2003"
Else
row.Item("Versions") = String.Concat(row.Item("Versions"), ", MS Project 2003")
EndIf
EndIf
i += 1
Next
Thanks!!
Dave
(...)
MyConnection = New System.Data.OleDb.OleDbConnection( _
"provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source=C:\Imitation Desktop\Parser_VB\Proj.xls; " & _
"Extended Properties=Excel 8.0;")
' Select the data from Sheet1 of the workbook.
MyCommand = New System.Data.OleDb.OleDbDataAdapter( _
"SELECT L_Region, P_Site, UserName, CompName, MSProject2000, MSProject2002, MSProject2003 from [Sheet1$]", MyConnection)
DS = New System.Data.DataSet()
MyCommand.Fill(DS)
MyConnection.Close()
'Dispose OLE controls
MyConnection.Dispose()
MyCommand.Dispose()
(...)
DS.Tables(0).Columns().Add("Versions", System.Type.GetType("System.String"))
(...)
ForEach row As DataRowView In dvView
row.Item("Versions") = ""
'Check flags to see if this version exists
If (alVers.Item(i).MS2000 = 1) Then
row.Item("Versions") = "MS Project 2000"
EndIf
If (alVers.Item(i).MS2002 = 1) Then
If (row.Item("Versions") = "") Then
row.Item("Versions") = "MS Project 2002"
Else
row.Item("Versions") = String.Concat(row.Item("Versions"), ", MS Project 2002")
EndIf
EndIf
If (alVers.Item(i).MS2003 = 1) Then
If (row.Item("Versions") = "") Then
row.Item("Versions") = "MS Project 2003"
Else
row.Item("Versions") = String.Concat(row.Item("Versions"), ", MS Project 2003")
EndIf
EndIf
i += 1
Next
Thanks!!
Dave