All
I use Access 2007 in combination with "MS SQL 2005".
On the SQL-server I imported the UberCrossTab-script in order to create dynamic Pivot tables.
When I launch the SQL-string on the SLQ-server, I do get the expected result in the "Results"-window.
I now need to use VBA-code in order to retrieve the data and column names in an ADODB.RECORDSET
Currently, I use next code. This does not give errors, so assume the data is somewhere in the recordset CN. But how can I read the table header names and the data.
I use Access 2007 in combination with "MS SQL 2005".
On the SQL-server I imported the UberCrossTab-script in order to create dynamic Pivot tables.
When I launch the SQL-string on the SLQ-server, I do get the expected result in the "Results"-window.
I now need to use VBA-code in order to retrieve the data and column names in an ADODB.RECORDSET
Currently, I use next code. This does not give errors, so assume the data is somewhere in the recordset CN. But how can I read the table header names and the data.
Code:
Private Sub Command110_Click()
Dim cn As ADODB.Connection
Dim cmd As ADODB.Command
Set cn = New ADODB.Connection
With cn
.Provider = "sqloledb"
.Properties("Data Source").value = strODBCServer
.Properties("Initial Catalog").value = strODBCdatabase
.Properties("Integrated Security").value = "SSPI"
.Open
End With
strSQL = "EXECUTE UberCrosstab @pivotRowFields = 'Location, Type' ,@pivotField = 'Date',@pivotTable = 'qryVMActualsClusterInfo',@aggField = 'Capacity',@aggFunc = 'SUM'"
cn.Execute strSQL
End Sub