Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > Read data from ExternalDataSource

Forum

Search UsersRules
Read data from ExternalDataSource
#1
Active user
Points:: 0
Joined:: Sep 27, 2023

Hi Experts,
 
i want to get data from external data source ExternalDataSources.XXXX.Tables.XXXX;

 how can i get all table data and iterate it,

 i tried like below but gives me error


 For Each DataRow In ExternalDataSources.XXX.Tables.XXXX Do

 EndDo;

Profile
#2
Administrator
Points:: 0
Joined:: Oct 3, 2019

Hello Selim!

None of the experts have answered you, so let me try to help you :)

For first - could you provide a more complete code?

And in general, it is better to work with external data sources using queries:



Code
   Query = New Query;
   Query.Text = 
      "SELECT
      |   dbo_CURRENCIES.CODE AS CODE,
      |   dbo_CURRENCIES.NAME AS NAME,
      |   dbo_CURRENCIES.STATUS AS STATUS,
      |   dbo_CURRENCIES.EXTCODE AS EXTCODE
      |FROM
      |   ExternalDataSource.RK_RKeeper7.Table.dbo_CURRENCIES AS dbo_CURRENCIES";
   
   QueryResult = Query.Execute();
   
   SelectionDetailRecords = QueryResult.Select();
   
   While SelectionDetailRecords.Next() Do
      // Insert selection processing SelectionDetailRecords
   EndDo;

Profile
#3
Active user
Points:: 0
Joined:: May 21, 2023

And how do you connect to external data source?

Profile
#4
Administrator
Points:: 0
Joined:: Oct 3, 2019

Hello Peter!

How to connect to an external source - this is material for a small article... :-)

I have prepared several screenshots. I hope it will be clear to you how to connect. If you have any questions - ask!

Profile
#5
Administrator
Points:: 0
Joined:: Oct 3, 2019

First we add an external source in the Designer:

Profile
#6
Administrator
Points:: 0
Joined:: Oct 3, 2019

Select the tables whose data we want to work with. Also pay attention to screenshot 7 - it is necessary that the key field is filled in!

Profile
#7
Administrator
Points:: 0
Joined:: Oct 3, 2019

Now we launch 1C in working mode and open the External Source there:

Profile
#8
Administrator
Points:: 0
Joined:: Oct 3, 2019

There is one nuance here - when connecting for the first time, we need to specify the login and password again. Or the easiest way is to use the connection string, which can be copied from the Designer:

Profile
#9
Administrator
Points:: 0
Joined:: Oct 3, 2019

After this, we can work with the data in the tables directly:

Profile
#10
Active user
Points:: 0
Joined:: Sep 27, 2023

Thank you for your help.

İs there another way to get all data from table without Query selection like below code

For Each DataRow In ExternalDataSources.XXX.Tables.XXXX Do

EndDo;

Profile
#11
Administrator
Points:: 0
Joined:: Oct 3, 2019

As far as I know, the table of the external data source cannot be iterated, so this code:

Code
For Each a In ExternalDataSources.ExternalDataSource1.Tables.HumanResources_Employee Do 
   
EndDo;


won't work.

But I'll check with the developers. Thanks for the question!

Profile
#12
Active user
Points:: 0
Joined:: Sep 27, 2023

Thank you for your help Sır

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



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