Search code examples
c#vb.nethp-quality-center

How do I generate a Quality Center recordset with C#?


I am converting an application that connects to Quality Center via the OTA API from VB.net to C#. The application makes extensive use of recordsets, but I have not been able to get them to work in C#.

Specifically, I have trouble casting Command and Recordset to the correct format for C#. Everything I have tried has failed.

Following, is an VB.net example of the code that I need to convert.

Private Function GetRecSet(ByVal Qry As String, TD as TDConnection) As Recordset

        Dim Com As Command = TD.Command
        Com.CommandText = Qry
        GetRecSet = Com.Execute
        GetRecSet.First()

End Function

Solution

  • After a bit of work, and a lot of banging my head against a wall, I came up with the following solution:

    static TDAPIOLELib.Recordset GetRecSet(String Qry, TDAPIOLELib.TDConnection TD)
            {
    
                TDAPIOLELib.Command Com;
                Com = TD.Command as TDAPIOLELib.Command;
                Com.CommandText = Qry;
    
                TDAPIOLELib.Recordset RecSet = Com.Execute() as TDAPIOLELib.Recordset;
                return RecSet;
    
            }
    

    It seems to do the job.