Jugulator
8/12/2018 - 10:47 AM

SQL to Recordset

Function SQLtoRecordset(ByVal objConn As ADODB.Connection, ByVal SQL_String As String) As ADODB.Recordset
'Description: Executes an SQL command
'Inputs:      Connection object; SQL command (string)
'Output:      Recordset object

'******   DEKLARÁCIÓK   ********************
Dim adoRecSet   As ADODB.Recordset
Dim cmd         As ADODB.Command
'*******************************************

    Set adoRecSet = New ADODB.Recordset
    Set cmd = New ADODB.Command
    
    With cmd
        .CommandText = SQL_String
        '.Parameters.Append .CreateParameter("ParameterName", adChar, adParamInput, 20, varName) --> ha valamelyik paraméter helyére ?-t írtunk
        .ActiveConnection = objConn
    End With
        
    Set adoRecSet = cmd.Execute(, , adCmdText)

   
    Set SQLtoRecordset = adoRecSet

End Function