Publish date: 2015-03-26

Work within ADODB connection. (C#)

////////////////////////////////////////////////////////////////////////////////
//Samples for LCPI ADO.NET Data provider for OLEDB.
//                                                                   26.03.2015.
using System;
using System.Data;
using System.Diagnostics;
using lcpi.data.oledb;

using com_lib=lcpi.lib.com;
using adodb_lib=lcpi.lib.adodb;

namespace Sample_0022{
////////////////////////////////////////////////////////////////////////////////
//class Program

class Program
{
 private const string c_cn_str
   ="provider=LCPI.IBProvider.3;"
   +"location=localhost:d:\\database\\employee.fdb;"
   +"user id=gamer;"
   +"password=vermut;";

 //-----------------------------------------------------------------------
 static int Main()
 {
  int resultCode=0;

  try //[catch]
  {
   dynamic adodbCn=com_lib.object_utils.CreateInstance
                    ("ADODB.Connection",
                     com_lib.ClsCtxCode.CLSCTX_INPROC_SERVER).GetObject();

   adodbCn.ConnectionString=c_cn_str;

   adodbCn.Open();

   adodbCn.BeginTrans();

   using(var oledbCn=new OleDbConnection())
   {
    oledbCn.AttachToNativeSession(adodb_lib.AdoDbConstructor.get_oledb_session_from_adodb_cn(adodbCn));

    using(var cmd=oledbCn.CreateCommand())
    {
     cmd.CommandText="select c.CURRENCY from COUNTRY c where c.COUNTRY=:country";

     cmd["country"].Value="USA";

     Console.WriteLine("currency: {0}",cmd.ExecuteScalar());
    }
   }//using oledbCn

   adodbCn.CommitTrans();
  }
  catch(Exception exc)
  {
   resultCode=1;

   Console.WriteLine("ERROR: {0} - {1}",exc.Source,exc.Message);
  }//catch

  return resultCode;
 }//main
};//class Program

////////////////////////////////////////////////////////////////////////////////
}//nms Sample_0022


Output of sample.
Output.