V82.COMConnector usage examples

1C:Enterprise platform integration capabilities and techniques

#1
People who like this:0Yes/0No
Just came
Rating: 0
Joined: Feb 26, 2012
Company:

Hi,

is there any more or less complete manual about using COM connection to V82.COMConnector with examples on Delphi/C#/C++?

 
#2
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Hi, Vladislav!
It is quite simple: you need to create a COM object and after that you can access global functions or export functions of modules where you can implement the functionality you like.
Here is the VBA example from Core Development Techniques Tutorial page 389.

Code
Module Module1
Sub Main()
  Dim cc As Object 'It will be a COM connector
  Dim con As Object
  Dim o,o2 As Object
  Dim e As Object
  Dim str As String
  Try
    cc = CreateObject("V82.COMConnector")
    con = cc .Connect ("File=c :/lcv8/mdcom;Usr=r\naBHbiii")
    o = con NewObject("Array", 5)
    o.Set(0 "Item 0")
    o.Set(1 "Item 1")
    o.Set(2 "Item 2")
    o.Set(3 "Item 3")
    o.Set(4 "Item 4")
    o.Set(5 "Item 5")
    Dim c As Integer = o.Count()
    For Each e In o
      Console.WriteLine(e.ToString())
    Next
    o2 = con.AllowedLength.Variable
    str = con.ValueStr(o2)
    Dim s As String = str
  Catch ex As Exception
    Console.WriteLine(ex)
  End Try
  con = Nothing
  cc = Nothing
  System.GC.Collect()
End Sub
End Module

 
#3
People who like this:0Yes/0No
Just came
Rating: 0
Joined: Feb 26, 2012
Company:

Ok, this is Delphi:

==

Code
program TestConnectTo1Cv8;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils, ComObj, V82_TLB, Variants;

var
  v8con: IV8ComConnector;
  v8obj: Variant;
  t: Variant;

begin
  try
    Writeln('Creating connector');

    v8con := CreateOleObject('V82.COMConnector') as IV8COMConnector;
    if VarIsEmpty(v8con) then
    begin
      Writeln('v8con is empty!');
      Exit;
    end;

    Writeln('Connect to DB');
    v8obj := v8con.Connect('Srvr=MYSERVER;Ref=MYDATABASE;Usr=MYUSERNAME;Pwd=MYPASSWORD');
    if VarIsEmpty(v8obj) then
    begin
      Writeln('v8obj is empty!');
    end;

    t := v8obj.Catalogs.Currencies.Select();
    t.Next();
    Writeln(t.Description);
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

==

This writes out first element of Currencies Catalog.

Edited: Vladislav Yaroslavlev - Dec 03, 2012 02:16 PM (code)
 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.