-
FlexPro
- At a Glance
- Features & Options
- Applications
- All Advantages
- What’s New in FlexPro 2021
- Try FlexPro For Free
- FlexPro View OEM Freeware
- Buying Guide
- Login
- Language
- +49 6894 929600
- infoweisang.com
- Google Maps
- Products
- News
- Support
- Company
- Contact
- Login
- Language
- +49 6894 929600
- infoweisang.com
- Google Maps
FPAccess
Home > Community > Automation and VBA > FPAccess
- This topic has 18 replies, 2 voices, and was last updated 17 years, 6 months ago by Mustapha Ghazzouz.
-
AuthorPosts
-
June 4, 2007 at 10:46 pm #12406Mustapha GhazzouzMember
Hello,
I´m trying to use the sample programm to create a new DB and then create some Datasets and signals. The programm should open my created Datasbase in FlexPro.
The server-object should be used in the LocalServer Mode.
the code looks like:
————————————————hErr = ::CoCreateInstance(CLSID_FPDatabaseAccessHelper, NULL, CLSCTX_LOCAL_SERVER /*CLSCTX_SERVER*/, IID_IFPDatabaseAccessHelper, (void**)&pFPDbAccessHelper); . . . BOOL bInProcess = FALSE; . . ShellExecute(NULL, "open", D:\FlexPro\myExamples\testdb.fpd", NULL, NULL, SW_SHOW); hErr = FPDbAccessHelper->GetDatabaseAccess( strDatabase, strMachine, &bInProcess, &pFPDbAccess); . . hErr = pFPDbAccess->CreateData(&strDataName, strFolder, TRUE, NULL, strComment, strUnit, NULL, strAuthor, strOrigin, NULL, NULL, dtFloat64, 0, 0, TRUE, &pFPStreamData); if(FAILED(hErr)) return PrintError(hErr, 5);
————————————————
the programm breaks with the error code 5
In Visual Studio I get a message in the output window that looks like this:First-chance exception at 0x7c812a5b in CSample.exe: 0x80010105: Ausnahmefehler des Servers.
The thread ‘Win32 Thread’ (0x9a0) has exited with code 5 (0x5).
The thread ‘Win32 Thread’ (0x940) has exited with code 5 (0x5).
The thread ‘__tmainCRTStartup’ (0x83c) has exited with code 5 (0x5).
The program ‘[348] CSample.exe: Native’ has exited with code 5 (0x5).Can someone explain to me what could be the reason
thanksJune 4, 2007 at 10:46 pm #8089Mustapha GhazzouzMemberHello,
I´m trying to use the sample programm to create a new DB and then create some Datasets and signals. The programm should open my created Datasbase in FlexPro.
The server-object should be used in the LocalServer Mode.
the code looks like:
————————————————hErr = ::CoCreateInstance(CLSID_FPDatabaseAccessHelper, NULL, CLSCTX_LOCAL_SERVER /*CLSCTX_SERVER*/, IID_IFPDatabaseAccessHelper, (void**)&pFPDbAccessHelper); . . . BOOL bInProcess = FALSE; . . ShellExecute(NULL, "open", D:\FlexPro\myExamples\testdb.fpd", NULL, NULL, SW_SHOW); hErr = FPDbAccessHelper->GetDatabaseAccess( strDatabase, strMachine, &bInProcess, &pFPDbAccess); . . hErr = pFPDbAccess->CreateData(&strDataName, strFolder, TRUE, NULL, strComment, strUnit, NULL, strAuthor, strOrigin, NULL, NULL, dtFloat64, 0, 0, TRUE, &pFPStreamData); if(FAILED(hErr)) return PrintError(hErr, 5);
————————————————
the programm breaks with the error code 5
In Visual Studio I get a message in the output window that looks like this:First-chance exception at 0x7c812a5b in CSample.exe: 0x80010105: Ausnahmefehler des Servers.
The thread ‘Win32 Thread’ (0x9a0) has exited with code 5 (0x5).
The thread ‘Win32 Thread’ (0x940) has exited with code 5 (0x5).
The thread ‘__tmainCRTStartup’ (0x83c) has exited with code 5 (0x5).
The program ‘[348] CSample.exe: Native’ has exited with code 5 (0x5).Can someone explain to me what could be the reason
thanksJune 4, 2007 at 11:27 pm #8656Bernhard KantzParticipantThe call to ShellExecute is likely causing the problem. First of all it is not necessary to do this as creating the datasets will work without this. If you really want to open FlexPro before you write to the database you should consider that ShellExecute will launch FlexPro asynchronously. This means your call to GetDatabaseAccess will be executed while FlexPro is being started. This may lead to timeout or other issues which will be difficult to debug.
If you need to open FlexPro you should do this before doing any Automation and stop/synchronize your code until FlexPro is up and running.
Support
support@weisang.comJune 5, 2007 at 12:54 am #8657Mustapha GhazzouzMemberthanks for the reply..
The same code did work last week, no I receive this message. I don´t understand why. No I try it even without starting flexpro (with CLSCTX_SERVER and InProcess=False/True) and still always get the same message!!!
Indeed, my intention is to create a DB, create some Datasets and signals, maybe make some analysing and then open the DB in Flexpro (and maybe select an Object with OpenObject()).
I think the LocalServer is the right modus, where my client-program should use Flexpro to access the DB (Flexpro-Docu). The docu also says that if I call GetDatabaseAccess() with InProcess=False, then the access-object will be created by starting Flexpro. That´s why I call ShellExecute() before GetDatabaseAccess().. I don´t know what I´m doing wrong.
June 5, 2007 at 1:09 am #8658Mustapha GhazzouzMemberI just restarted my PC and run the same code and it works again. I have no explanation for it!!!
June 5, 2007 at 2:07 am #8659Bernhard KantzParticipantAs already pointed out using ShellExecute will start FlexPro asynchronously and progress to your GetDatabaseAccess call while FlexPro is starting or opening the database.
Depending on the circumstances (FlexPro is already running, running of other applications etc.) opening the database may be fast or slow. In general FlexPro will not be responsive to incoming Automation calls when starting up and there may be time-out issues depending on the time it takes to start on the target machine. Attaching to the database requires some COM operations which might also fail when FlexPro is starting up and opening a database.
So in the end it may sometimes work and somtimes fail. There a several ways to get a deterministic behavior:
[list]Force a synchronized start of FlexPro before doing automation calls. This may be a bit tricky when using ShellExecute.
Do the Automation calls first (they are synchronous) and start FlexPro at the end of your work.
If you are using FlexPro Professional you should use the Databases.Open method. It does what you want to do in a synchronous way. In this case you should investigate your code if you need the FPAccess Interfaces at all and prefer the FlexPro Automation Model whenever possible.
[/list]
Support
support@weisang.comJune 5, 2007 at 3:47 am #8660Mustapha GhazzouzMemberIt looks like I should choose either the first or third way. For the first one I should look how to do it. For the third one It would be nice if there is any little introducing example for how to use the Flexpro-Objectmodell.
thanks again for the helpful answer
June 5, 2007 at 8:07 pm #8661Bernhard KantzParticipantIf you have the choice you should use the third approach.
If you are using the FlexPro object model from an external program (not VBA) your code might look like this:
Dim oApp As Application Dim oDb As Database ' start FlexPro Set oApp = CreateObject("FlexPro.Application") ' open the database Set oDb = oApp.Databases.Open([some database]) ' make the application visible oApp.Visible = True
To learn the FlexPro object model you should start out doing the things you want to automate manually and record the actions as a (VBA) macro. Then you can take the macro and tweak it further to your needs.
The online help contains also some work throughs for common tasks (like writing data) and a detailed description of three complete usage examples, which can be found in the folder ExamplesVBA in the FlexPro installation folder. In the VBA development environment you can get help for any object, property or method from the object model by pressing F1 on the name.
Support
support@weisang.comJune 12, 2007 at 11:05 pm #8662Mustapha GhazzouzMemberThe only reason why I use the FPAccess interface is that it works better mit big data (FlexPro-Docu).
One more question, how can I call (or tell FlexPro to call) a recorded VBA-Script from my VB- or C++ Programm ?
June 13, 2007 at 3:06 am #8663Bernhard KantzParticipantYou can use the Run-method of the FlexPro application object.
Example:
... Dim oFlexPro As FlexPro.Application Set oFlexPro = CreateObject("FlexPro.Application") ... 'call the macro "Test" of the active database Call oFlexPro.Run("ActiveDatabase!Test") 'call the quick macro saved into the personal template database Call oFlexPro.Run("PersonalTemplateDatabase!QuickMacro") ...
June 16, 2007 at 1:43 am #8664Mustapha GhazzouzMemberHi..
Thanks for all the helpful answers.. I´m trying it again with the FPAccess with LocalServer-Modi, but I have a problem that I don´t understand.
First, COM is initialised and then an instance of the COM server object (pFPDbAccessHelper) is created through the automatic start of FlexPro.exe (I can see it in the Windows TaskManager)
::OleInitialize(NULL); hErr = ::CoCreateInstance(CLSID_FPDatabaseAccessHelper, NULL, CLSCTX_LOCAL_SERVER, IID_IFPDatabaseAccessHelper, (void**)&pFPDbAccessHelper);
Then I create a new database (strDatabase)
hErr = pFPDbAccessHelper->CreateDatabase(&strDatabase, crdbDirectory, &bOkay);
Untill here everything is ok.
But when I try to call GetDatabaseAccess()
hErr = pFPDbAccessHelper->GetDatabaseAccess(strDatabase, strMachine, &bInProcess, &pFPDbAccess);
I get the error “Klass is not registered”. What does this exactly means??
June 16, 2007 at 3:24 am #8665Bernhard KantzParticipantThe error means that a COM class is not known to the system and therefore no instance can be created. As GetDatabaseAccess does a lot COM related stuff it is difficult to say where the error happens. We suggest the following procedure:
Ensure that everything needed is registered properly: Go to a command line and switch to the FlexPro installation directory (normally [ProgramFiles]WeisangFlexPro 7.0) and execute the following commands in the given order:
flexpro /regserver regsvr32 fpaccess.dll regsvr32 fpproxystub.dll
Try if the C++-sample program located in [ProgramFiles]WeisangFlexPro 7.0DeveloperCPP is running. If you get an error please give us the complete and exact error description (no translation please) which is printed by the function PrintError and don’t forget to include the exact FlexPro version you are using.
If the sample program is running try again with your code.
Support
support@weisang.comJune 17, 2007 at 3:41 am #8666Mustapha GhazzouzMemberI did the registration of the DLLs successfully and tried the original c++ example (CLSCTX_SERVER and Inprocess=FALSE), but it doesn´t work. I´m using Flexpro Version 7.0.17 Professional edition..
Here is the complete error description:
————————————————-
"CSample.exe": "C:ProgrammeWeisangFlexPro Demo 7.0DeveloperCPPDebugCSample.exe" geladen, Symbole wurden geladen. "CSample.exe": "C:WINDOWSsystem32 tdll.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32kernel32.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32ole32.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32advapi32.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32 pcrt4.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32gdi32.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32user32.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32msvcrt.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32oleaut32.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32uxtheme.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32clbcatq.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32comres.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32version.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32msi.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:ProgrammeWeisangFlexPro Demo 7.0FPAccess.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32mpr.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:ProgrammeWeisangFlexPro Demo 7.0mfc71.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:ProgrammeWeisangFlexPro Demo 7.0msvcr71.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32shlwapi.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32comdlg32.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32comctl32.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32shell32.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:ProgrammeWeisangFlexPro Demo 7.0msvcp71.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSWinSxSx86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03comctl32.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:ProgrammeWeisangFlexPro Demo 7.0DEUFPAccessResources.dll" geladen, Die Binärdaten wurden nicht mit Debuginformationen erstellt. "CSample.exe": "C:WINDOWSsystem32apphelp.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:ProgrammeTortoiseSVNinTortoiseSVN.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32wininet.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32crypt32.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32msasn1.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:ProgrammeTortoiseSVNinlibapr_tsvn.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32ws2_32.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32ws2help.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32mswsock.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSWinSxSx86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.163_x-ww_681e29fbmsvcr80.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:ProgrammeTortoiseSVNinlibaprutil_tsvn.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:ProgrammeTortoiseSVNinlibapriconv_tsvn.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:ProgrammeTortoiseSVNinintl3_svn.dll" geladen, Die Binärdaten wurden nicht mit Debuginformationen erstellt. "CSample.exe": "C:WINDOWSWinSxSx86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.163_x-ww_681e29fbmsvcp80.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32shfolder.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:ProgrammeTortoiseSVNiconvwindows-1252.so" geladen, Keine Symbole geladen. "CSample.exe": "C:ProgrammeTortoiseSVNiconvwindows-1252.so" entladen. "CSample.exe": "C:ProgrammeTortoiseSVNiconv\_tbl_simple.so" geladen, Keine Symbole geladen. "CSample.exe": "C:ProgrammeTortoiseSVNiconvwindows-1252.so" geladen, Keine Symbole geladen. "CSample.exe": "C:ProgrammeTortoiseSVNiconvutf-8.so" geladen, Keine Symbole geladen. "CSample.exe": "C:ProgrammeTortoiseSVNiconvwindows-1252.so" entladen. "CSample.exe": "C:ProgrammeTortoiseSVNiconv\_tbl_simple.so" entladen. "CSample.exe": "C:ProgrammeTortoiseSVNiconvutf-8.so" entladen. "CSample.exe": "C:ProgrammeTortoiseSVNiconvwindows-1252.so" geladen, Keine Symbole geladen. "CSample.exe": "C:ProgrammeTortoiseSVNiconvwindows-1252.so" entladen. "CSample.exe": "C:ProgrammeTortoiseSVNiconv\_tbl_simple.so" geladen, Keine Symbole geladen. "CSample.exe": "C:ProgrammeTortoiseSVNiconvwindows-1252.so" geladen, Keine Symbole geladen. "CSample.exe": "C:ProgrammeTortoiseSVNiconvutf-8.so" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32cscui.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32cscdll.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32rowseui.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32userenv.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32setupapi.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32 tshrui.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32atl.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32 etapi32.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32shdocvw.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32cryptui.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32wintrust.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32imagehlp.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32wldap32.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32 iched20.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32 iched20.dll" entladen. "CSample.exe": "C:ProgrammeYahoo!Messengeridle.dll" geladen, Keine Symbole geladen. "CSample.exe": "C:WINDOWSsystem32xpsp2res.dll" geladen, Die Binärdaten wurden nicht mit Debuginformationen erstellt. Der Thread 'Win32 Thread' (0x928) hat mit Code 3 (0x3) geendet. Der Thread 'Win32 Thread' (0x914) hat mit Code 3 (0x3) geendet. Der Thread 'Win32 Thread' (0x92c) hat mit Code 3 (0x3) geendet. Der Thread 'Win32 Thread' (0xed8) hat mit Code 3 (0x3) geendet. Der Thread 'Win32 Thread' (0x924) hat mit Code 3 (0x3) geendet. Der Thread 'Win32 Thread' (0x90c) hat mit Code 3 (0x3) geendet. Das Programm "[2284] CSample.exe: Systemeigen" wurde mit Code 3 (0x3) beendet.
————————————————–
While debuging it I get in the hErr the value “Klasse nicht registriert” ( I´m using Microsoft Visual Studio 2005 Version 8.0.)
Though, the example does work successfully when I change Inprocess to TRUE.
June 18, 2007 at 8:36 pm #8667Bernhard KantzParticipantWe tried to reproduce this, but everything works as intended… When looking at your debugger output we noticed that the path to FlexPro contains ‘FlexPro Demo 7.0’. Do you have the demo version and the Professional version on your system? In case you had the demo before you purchased the Pro version: Please uninstall both the Pro and the demo (this order) and re-install the Pro version again. Due to the nature of COM and the behaviour of the Windows Installer you might get unpredictable results when having both versions on a system (with possibly different build versions) and using COM.
If the problem persists try to re-register the files ole32.dll and oleaut32.dll using regsvr32 (the files are located in C:\Windows\System32). Sometimes parts of their registration is lost thus leading to strang behaviour also.
If the problem still persists please start FlexPro first, then run the automation sample and tell us about your experience.Support
support@weisang.comJune 18, 2007 at 10:56 pm #8668Mustapha GhazzouzMemberAt work I´m using the prof. Version 7.0.11, and at home I´ve installed the demo version 7.0.17. So, I don´t have both versions on one system.
I´m now at work and I just tested again and I remark that the original CExample works only with example-DBs of Flexpro (C:\Programme\Weisang\FlexPro 7.0\Beispiele), but not with the DBs I create myself with Flexpro..
I also registered the ole32.dll and oleaut32.dll using regsvr32 but I always get the same error.
When I start Flexpro and then run the example, it does not work. though When I start Flexpro open my DB and then run the example, it works. (That´s why I always tried to call ShellExecute() before GetDatabaseAccess())
I´m sending u a simple testDB I use, so u could maybe reproduce the error
-
AuthorPosts
- You must be logged in to reply to this topic.