views:

408

answers:

1

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
A: 

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.

JonnyGold