• Welcome to PlanetSquires Forums.

Help connectING to my NOSQL database using WinFBE/WinFBX

Started by Flavio Fornazier, July 21, 2022, 11:10:55 PM

Previous topic - Next topic

Flavio Fornazier

Hi all!

First of all, congratulations to WinFBE/WinFBX authors, co-workers and users.

As far as possible, I'm still reading the documentation, examples and posts from all available forums,  so I apologize if I'm in wrong place, but I just have one question and I would greatly appreciate any reply.

I would like to use WinFBE/WinFBX to connect to my NOSQL database trought its own Activex DLL. In VB6, at form level, after add the reference to the object, I do the following:

General ---> Declarations
Public WithEvents m As MiniMSCXLib.ServerConnect

Private Sub Command1_Click()
        Set m = New MiniMSCXLib.ServerConnect
        Dim ret As Long
        '  the three parameters below are string, long and string
        ret = m.CreateConnect("localhost", 5000, "user")
        ret = m.Open
        ' parameter below is a string and I get the result of the call in
        'the "OnTerminalOutput" event
        ret = m.ExecuteOutputStr("W $ZV")
        Set m = Nothing
End Sub

' Here the event, as described above.
Private Sub m_OnTerminalOutput(ByVal Value As String)
    Text1.Text = Value
End Sub

-  It's not my intention to make apology for VB6, it was just the easiest way that I found to explain my case.
- There's no error handling just to simplify the code.

Thank you in advanced.

Paul Squires

Hi Flavio,

It appears that this is the database that you are attempting to use?

ActiveX is not something that WinFBE does but Jose's WinFBX has been known to work with some non-visual ActiveX / COM products. Being a database and non-visual, it may work.

A better choice may be to use a standard Windows DLL rather than an ActiveX. I did a quick search on the site and I stumbled across the attached files that show a standard C header file and example C code that will dynamically load the database functions. I think that using this approach may be the easiest approach in the long run.

I will try downloading the product and see if I can do the conversion. I will also try if I can use Jose's ActiveX files.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

Attached is my conversion of the code. It works on my computer. I installed the 64-bit version of the database server and connected to the 64-bit version of the client DLL (which I also included in the attached zip file). You may have to adjust the filename path in the source code if you locate your client DLL in a different path.

I complied the example code EXE using WinFBE and 64 bit console (release) mode.

The code dynamically loads the DLL and gets the function addresses to all of the various database functions. The example code seems to work correctly.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Flavio Fornazier

Hi Mr.Paul,

I still don't know how to say thank you to such a respected person like you. I already loved your sense of humor and now I have discovered another reason why you're so loved by Freebasic community. After you write a lot of code, the least I can do is explain you something about.

It's a MUMPS implementation, as far as I know the first NoSQL database of the world (1966) and, of course, there are commercial and open source versions.

Just to make you laugh, in this particular case, I play the role of "Basic Languages Lawyer" (to be more precise "the most annoying lawyer"), that is, always encouraging (or forcing? lol) the author to write examples for all the Basic's Languages on the road. But as you may have noticed, there was no FreeBasic examples and I've been already going crazy with him because in my opinion Freebasic should be the first. lol =)

Well, now I will compile your example, write some code, use it, and, with your permission, I'll send it to be embedded in the installer.

Thank you very much!

PS: I'm using WinFBE source code to learn more about Freebasic, nothing better than learning from the best.

Flavio Fornazier

Hi Mr.Paul,

Your code works great, much better than expected. If you'll excuse me, I just have one little question for you, my doubts were written as comments, I'm afraid to use bad practices. To get a big volume of data, as well highest performance, I wrote one of the three possible event handlers.

Declared in the header file
type mnmgroupreadproc_t as sub(byval pConnect as HMNMConnect, byval Value as MINIMSTR ptr) '// second parameter is a pointer
type mnmsetgroupread_t as sub(byval pConnect as HMNMConnect, byval pProc as mnmgroupreadproc_t)

Declared in module file
MNMSetGroupRead = cast(mnmsetgroupread_t, GetProcAddress(hLib, "MNMSetGroupRead"))

My code for event handler
Public Sub GroupReadProc( byval Connect as HMNMConnect, byref Value As MINIMSTR)  '// Works fine, but can I use "byref" in the second parameter?
   frmmain.Text1.Text = frmmain.Text1.Text + Value.data
End Sub

My code to get data from server and receive it at above event
MNMSetGroupRead( Connect, Cast(any ptr, @GroupReadProc)) '// Works fine, but can I use "cast" and "any ptr" in the second parameter?
   dim t_ret as integer
   expr.data = "n i f  i=1:1:500 d wo^%srv(i_$zh)"
   expr.len = len(expr.data)
   t_ret = MNMExecute( Connect, @expr)
   if t_ret = 0 then
      HandleMNMError( Connect): exit function
   end if
   MNMSetGroupRead( Connect, NULL)  '// Can I use "NULL"?

Well, your opinion will be very helpful, so that I can improve this work.

Thank you in advanced.