How to use ODBC in a correctly way?

How to use ODBC in a correctly way?

ben_k2
Not applicable
26 Views
10 Replies
Message 1 of 11

How to use ODBC in a correctly way?

ben_k2
Not applicable

[ FlexSim 18.2.2 ]

Hey guys,

I have a problem with my database connection. I am using MySQL80.

Everything is working, when I am using the FlexSim DBConnector (picture 1). There is not any error meesage when I am runing the short FlexSim code.

pic1

16368-1-dbconnector-is-working.png

Unfortunately I have a FlexSim model, which was created befor FlexSim DBConnector was implemented. Due to this I need to use ODBC. I created an new DSN in ODBC, wich could found my SQL database successelful. But I cannot open the database in FlexSim via ODBC. I wrote a short Flexsim Command to illustrad it. I get a exception. You can see it on picture 2 and 3.

pic 2

16369-2-error-with-odbc.png

pic 3

16371-3-error-with-odbc.png

Maybe you have any idea to solve the issue. The exception is not helpful for me.

Feel free to ask me anything about my system. I am looking forward to your solution. Excuse my english skill. I am not a native speaker.

Best regards

Ben

Accepted solutions (1)
27 Views
10 Replies
Replies (10)
Message 2 of 11

philboboADSK
Autodesk
Autodesk

You said, "Unfortunately I have a FlexSim model, which was created befor FlexSim DBConnector was implemented."

Can you not open that model in a version of FlexSim where the DBConnector is available?

Models built in older versions of FlexSim should open and upgrade to newer versions just fine.



Phil BoBo
Sr. Manager, Software Development
0 Likes
Message 3 of 11

philboboADSK
Autodesk
Autodesk

Also, did you try following the steps in this tutorial? Perhaps something described there can help you understand what is misconfigued.



Phil BoBo
Sr. Manager, Software Development
0 Likes
Message 4 of 11

jason_lightfootVL7B4
Autodesk
Autodesk

As that tutorial explains the DSN should be added using odbcad32.exe found at %windir%\syswow64\odbcad32.exe or %windir%\system32\odbcad32.exe depending on whether you're connecting via 32bit or 64 bit FlexSim.

0 Likes
Message 5 of 11

ben_k2
Not applicable

It is a complex model, wich was designed in FlexSim 7.3.. Now I am using a new computer with Flexsim 18.2.. So it would be to much work to use DBConnector instead of the "dbopen" commands.

I am reinstalled the ODBC connector and used the newest version. Futhermore I payed attention for the right architecture. Both are 64 bit versions. I reached a small goal:

"dbopen("flexsimdata","productionplan",1);" does not return a error anymore. But it returns the value 2. You can see it on the screenshot. This commands should give 1 for success, 0 otherwise.

16474-4.png

Any interact with the SQL datenbase still does not work. You can see a error on the secound screenshot. The cell exist in row 2 and col 2. So this is not the error.

16476-5.png

0 Likes
Message 6 of 11

jason_lightfootVL7B4
Autodesk
Autodesk

It looks like the mode is returned so 2 for table, 1 for SQL. Can you try in SQL mode rather than table mode?

dbopen("flexsimdata","SELECT * FROM productionplan",0);  //could also be SELECT NULL
dbsqlquery("UPDATE productionplan SET Wickelfertigung=2 WHERE ID=2");
dbclose();
0 Likes
Message 7 of 11

ben_k2
Not applicable

I tried your code. When I open the smulation and run the code for the first time, then I do not get any error message and the "Value" is change d to 0. But there is nothing changed in my sql table. When I run the code again, I get the a error message "exception: FlexScript exception: /0 c: /testlink_instance i: /testlink_associated".

0 Likes
Message 8 of 11

ben_k2
Not applicable

I could specified the issue. The "dbgettablenum"-command works perfectly. It is the "dbsettablenum", whiche causes error. Maybe it is problem about the rights of ODBC connector. So it can read but it cannot write.

0 Likes
Message 9 of 11

philboboADSK
Autodesk
Autodesk
Accepted solution

If you don't want to upgrade your model to 18.2, you can simply just continue to run this model in FlexSim 7.3.6.

You can install FlexSim 7.3.6 and FlexSim 18.2 on the same computer with the same license. A FlexSim license will work for any and all FlexSim versions <= the version of the license.



Phil BoBo
Sr. Manager, Software Development
0 Likes
Message 10 of 11

felix_g2
Not applicable

I tried the exact same code (and same ODBC-configuration, same MySQL-Database) meaning dbsettablenum in Flexsim 18.2.2 and Flexsim 7.3.6. It works fine in the older version but not in the newer one. This is really strange.. Might this be some bug in the newer version?

Also: Getting data from the database, e.g. with dbgettablenum, works (for both versions).

0 Likes
Message 11 of 11

philboboADSK
Autodesk
Autodesk

FlexSim 17.1.0 included the following bug fix:

  • Fixed an issue with writing to Access databases with read-only fields.

This changed the code in dbsettablenum().

It is possible that this bug fix introduced the issue you are experiencing.



Phil BoBo
Sr. Manager, Software Development
0 Likes