binary DBF access in the X# runtime

This forum is meant for questions and discussions about the X# language and tools
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

binary DBF access in the X# runtime

Post by wriedmann »

Hi,
is there any possibilty to get binary data from a DBF field using the X# runtime?
Thank you very much!
Wolfgang
P.S. another thing: when I call a X# VO dialect library from a X# Core application: is there any need to initialize the runtime like it was needed with the Vulcan runtime?
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

binary DBF access in the X# runtime

Post by robert »

Wofgang,
Thanks for reminding me.
I will add a FieldGetBytes() function that reads the bytes directly from the buffer in the DBF
and a FieldPutBytes()
What you can do in the mean time:

Code: Select all

LOCAL oRDD as IRDD
oRdd := (IRDD) DbInfo(DBI_RDD_OBJECT)
// get the bytes from the current record
local aBytes as Byte[]
aBytes := oRDD:GetRec()
// manipulate the bytes

// and to write the bytes
oRDD:PutRec(aBytes)
// (not tested but this should work)
And there is no need to initialize the runtime afaik.
But please remember: even if you use X# Core, the Macro compiler will "silently" load XSharp.RT because it needs the USUAL type and CODEBLOCK type that are defined in XSharp.RT. So XSharp.RT should be available at runtime.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

binary DBF access in the X# runtime

Post by wriedmann »

Hi Robert,

thank you very much!
Your code will also work for memo fields? I'm mostly using memo fields to store bitmaps or compressed content (or both at the same time as bitmaps have a good compression ratio), and sometimes also for crypted content.

Of course I will make sure the RT and Macro compiler DLL are available at runtime, as they are needed by the VO dialect library.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

binary DBF access in the X# runtime

Post by robert »

Wolfgang,
No this does not work for memo fields.
In the case of memo fields, the buffer contains the location of the memo in the file. To read the memo you have move the file to the right location.
You can use DbInfo(DBI_MEMOFIELD, nFieldPos) to retrieve the location of the memo in the DBT/FPT file and then retrieve the memo file handle with DBI_MEMOHANDLE, and read the data yourself.
But I will take care of this in a next build.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

binary DBF access in the X# runtime

Post by wriedmann »

Hi Robert,
I suspected that as I have some experience accessing DBF files in a binary mode.
It is not urgent, but it would be a good thing to have it in the next build.
Currently I will start to migrate my Dictionary Editor to the X# runtime and use it myself - but many other applications, including my most important ones, need the binary data.
Maybe in the meantime the trick (by Chris <g>) will help:
https://www.xsharp.eu/forum/public-vo-v ... o-a-sql-db
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

binary DBF access in the X# runtime

Post by Chris »

Hi Wolfgang,

I had completely forgotten about that! But, yeah this trick should work also with the X# RDD for storing/reading binary data, as it makes an extra conversion which negates the binary<->text conversion .that the RDD makes. Remember to use the simpler version of the code in post 2686: https://www.xsharp.eu/forum/public-vo-v ... ql-db#2686

Of course Robert's solution will be a lot faster, as it will return/store the raw bytes, with no conversions at all.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

binary DBF access in the X# runtime

Post by wriedmann »

Hi Robert,
And there is no need to initialize the runtime afaik.
But please remember: even if you use X# Core, the Macro compiler will "silently" load XSharp.RT because it needs the USUAL type and CODEBLOCK type that are defined in XSharp.RT. So XSharp.RT should be available at runtime.
I can confirm that - my production planning application (that I have currently in development) works perfectly also with the X# runtime (and DBFCDX) without any special initialization.
The (Core dialect) WPF application is reading data from DBFs and PostgreSQL sources and writing to PostgreSQL databases (from where my VO application accesses it using a X# COM module).

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
FFF
Posts: 1521
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

binary DBF access in the X# runtime

Post by FFF »

Why do you need COM? Doesn't npgsql work for you?
Only curious...
Regards
Karl
(on Win8.1/64, Xide32 2.19, X#2.19.0.2.)
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

binary DBF access in the X# runtime

Post by wriedmann »

Hi Karl,

using the .NET data access I don't need anything to install on the machines. This approach works very well with MySQL, SQLite and PostgreSQL.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Juraj
Posts: 161
Joined: Mon Jan 09, 2017 7:00 am

binary DBF access in the X# runtime

Post by Juraj »

Hi Wolfgang,

If I want to use an existing MySQL database using COM, do not need to install a MySQL server on the machines ?

Juraj
Post Reply