Scenario one:
I have a variety of sql tables. The number of columns varys from 27 to 59. The columns headings are numbers, commencing with 1 and incremented by 1. (and the rows are dates)
The data in the columns is either 1 or null .
I have built a simplistic stored procedure that 'pairs' the columns when there is a '1' in each
ie It returns a count of 57 for column one, because there are 57 1's in that column
it reurns 15 as a count of column 1 and 2 (because there are 15 1's in each column on the same date)
it returns 11 as a count of column 1 and 3.
It does this for all 470 , or so, results.
I have tried to bind this to a datagrid but just get one huge line of results.
The results should fill a triangular shaped (jagged) array, but I have not been able to get the data into the array and then the array into a table.
Can anyone assist, please? Any suggestions at all?
Scenario 2:
Same sql tables as for scenario one. However, from the stored procedure, I have placed the results back into a sql table which I have then bound to a datagrid.
In order to create the jagged nature of the table, I have had to use 'null' values to blank out the boxes as needs be.
I have also had to apply a sort (by descending) to the datagrid as the stored procedure is not populating the SQL table in the order I expected.
Ideally, all I want to do, is to directly access the my original data table / iterate through each column/pair of columns to obtain my results set / fill a jagged array with the results and use the array to create a corresponding table.
Perhaps something along the following lines (which of course, doesn't work....).
Any replies in Visual Basic would be appreciated....
'Public Sub ColumnList(ByVal MyTestTable As Data.DataTable)
' Dim myConnection As New SqlConnection()
' myConnection.ConnectionString = "Data Source=.\MySQLServer;AttachDbFilename=|DataDirectory|\XXXXXXX.mdf;Integrated Security=YYYYYYY;User Instance=ZZZZZZ"
' Dim myColumns As Data.DataColumnCollection = MyTestTable.Columns
' Dim column As Data.DataColumn
' Dim row As Data.DataRow
' Dim r As Integer
' For Each row In MyTestTable.Rows
' For Each column In MyTestTable.Columns
' r = "COUNT(column(row) + column(row)) AS Expr"
' Next
' Next
' Dim table1()() As Integer = New Integer(29)() {}
' Dim myColumnHeaders As Integer
' 'Dim r As Integer
' For myColumnHeaders = 0 To 29
' table1(myColumnHeaders) = New Integer(r + 1) {}
' Next myColumnHeaders
'End Sub
Where XXXXXXXX represents the name of my database and MyTestTable represents the table being queried.
Can anyone help? Thank you.
I have a variety of sql tables. The number of columns varys from 27 to 59. The columns headings are numbers, commencing with 1 and incremented by 1. (and the rows are dates)
The data in the columns is either 1 or null .
I have built a simplistic stored procedure that 'pairs' the columns when there is a '1' in each
ie It returns a count of 57 for column one, because there are 57 1's in that column
it reurns 15 as a count of column 1 and 2 (because there are 15 1's in each column on the same date)
it returns 11 as a count of column 1 and 3.
It does this for all 470 , or so, results.
I have tried to bind this to a datagrid but just get one huge line of results.
The results should fill a triangular shaped (jagged) array, but I have not been able to get the data into the array and then the array into a table.
Can anyone assist, please? Any suggestions at all?
Scenario 2:
Same sql tables as for scenario one. However, from the stored procedure, I have placed the results back into a sql table which I have then bound to a datagrid.
In order to create the jagged nature of the table, I have had to use 'null' values to blank out the boxes as needs be.
I have also had to apply a sort (by descending) to the datagrid as the stored procedure is not populating the SQL table in the order I expected.
Ideally, all I want to do, is to directly access the my original data table / iterate through each column/pair of columns to obtain my results set / fill a jagged array with the results and use the array to create a corresponding table.
Perhaps something along the following lines (which of course, doesn't work....).
Any replies in Visual Basic would be appreciated....
'Public Sub ColumnList(ByVal MyTestTable As Data.DataTable)
' Dim myConnection As New SqlConnection()
' myConnection.ConnectionString = "Data Source=.\MySQLServer;AttachDbFilename=|DataDirectory|\XXXXXXX.mdf;Integrated Security=YYYYYYY;User Instance=ZZZZZZ"
' Dim myColumns As Data.DataColumnCollection = MyTestTable.Columns
' Dim column As Data.DataColumn
' Dim row As Data.DataRow
' Dim r As Integer
' For Each row In MyTestTable.Rows
' For Each column In MyTestTable.Columns
' r = "COUNT(column(row) + column(row)) AS Expr"
' Next
' Next
' Dim table1()() As Integer = New Integer(29)() {}
' Dim myColumnHeaders As Integer
' 'Dim r As Integer
' For myColumnHeaders = 0 To 29
' table1(myColumnHeaders) = New Integer(r + 1) {}
' Next myColumnHeaders
'End Sub
Where XXXXXXXX represents the name of my database and MyTestTable represents the table being queried.
Can anyone help? Thank you.