Welcome to weblogs.com.pk Sign in | Join | Help

Disconnected (ADODB) Recordset

The good thing about .NET is its inter-operateability with older technologies; like COM.

If you are stuck with old platforms (like me J) you may find this post useful. Here you will find how to use ADODB (The classic ADO) with .NET

 

  • ADODB expects integer (INT32) parameters for the connection type and command types. The ADODB’s ENUM cannt be directly converted. We have to take care of this.

Here is the portion of code; how a disconnected recordset is being returned from C#

 

 

int connMode = (int) ADODB.ConnectModeEnum.adModeUnknown;

int cmdType = (int) ADODB.CommandTypeEnum.adCmdText;

 

ADODB.Recordset rs = new ADODB.RecordsetClass();

ADODB.Connection cn = new ADODB.ConnectionClass();

rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient;

object o = Type.Missing;

try

{

            cn.Open(Constants.ConnectionString, "", "", connMode);

            rs.Open(sql, cn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, cmdType);

            rs.ActiveConnection = null;

}

catch {throw; }

finally

{

            try

            {

                        cn.Close();

            }

            catch {}

}

Published Saturday, March 19, 2005 8:50 PM by khurram
Filed under: , ,

Comments

No Comments

New Comments to this post are disabled