Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Integration > V82.COMConnector usage examples

Forum

Search UsersRules
V82.COMConnector usage examples
#1
Just came
Points:: 0
Joined:: Feb 26, 2012

Hi,

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

Profile
#2
Guest
Points::
Joined::

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

Profile
#3
Just came
Points:: 0
Joined:: Feb 26, 2012

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.

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.