1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| Function getTransposedRows(connectionString As String, CommandType As CommandTypeEnum, sql As String, Optional Parameters)
Dim Rows
Rows = getRows(connectionString, CommandType, sql, Parameters)
If Not IsEmpty(Rows) Then getTransposedRows = Transpose(Rows)
End Function
Function getRows(connectionString As String, CommandType As CommandTypeEnum, sql As String, Optional Parameters)
Dim cn As New ADODB.Connection
Dim cm As New ADODB.Command
Dim pm As ADODB.Parameter
Dim Counter As Long
Dim rs As ADODB.Recordset
cn.Open connectionString
cm.ActiveConnection = cn
cm.CommandText = sql
cm.CommandType = CommandType
If Not IsMissing(Parameters) Then
For Counter = 0 To UBound(Parameters)
cm.Parameters.Append Parameters(Counter)
Next
End If
Set rs = cm.Execute()
If Not rs.EOF Then getRows = rs.getRows()
rs.Close
cn.Close
End Function
Function getParameter(Name As String, _
ParamType As ADODB.DataTypeEnum, _
Direction As ADODB.ParameterDirectionEnum, _
size As Long, _
ByVal Value) As ADODB.Parameter
Set getParameter = New ADODB.Parameter
With getParameter
.Name = Name
.Type = ParamType
.Direction = Direction
.size = size
.Value = Value
End With
End Function |
Partager