ODBC Problems (Connecting Vensim to MS Access)

Use this forum to post Vensim related questions.
Post Reply
Mohammad Jalali
Member
Posts: 20
Joined: Wed Mar 07, 2012 10:50 pm
Vensim version: DSS

ODBC Problems (Connecting Vensim to MS Access)

Post by Mohammad Jalali »

I am using a vdi file to read data from an Access database. I can get variables but constants. My ":CONSTANTS" keyword includes the followings:

:CONSTANTS
:VARNAME ConstantName
:VALUE ConsVal
:SELECT Constant_Val
! "Constant_Val" is a table in my database where I define value for each constant. The table includes: ConsName and ConsVal.

In the Vensim model, I create a new Constant to get one of the constant values from database (Let's name it as "C1" for which the type is set to be Constant). Then the problem is that I have to put a constant value to run the simulation (I entered 1). If I do so, it doesn't tell Vensim that the constant value should be read from the database. I assumed vdi is going to change the constant value after simulation runs, which was not a correct assumption. Then, I changed the type to be Data, the type that I use to read my variables from database, but when I run the simulation I get this WARNING: "No data found for C1 in the exogenous data file." which makes sense because C1 is not a variable and so it is not associated with time.

So, any idea how to use :CONSTANTS?

Note: Vensim model, Access database, and vdi file are attached!

Thanks,
M.J.
Attachments
ODBS_Read_Example.zip
To run the simulation, make sure that the :CONNECT keyword in your vdi file is updated based on the directory in your computer.
(23.69 KiB) Downloaded 248 times
Last edited by Mohammad Jalali on Thu Mar 22, 2012 4:30 am, edited 4 times in total.
Mohammad Jalali
Member
Posts: 20
Joined: Wed Mar 07, 2012 10:50 pm
Vensim version: DSS

Re: ODBC Problems (Connecting Vensim to MS Access)

Post by Mohammad Jalali »

I just found out what was missing in the model!
I only set the input file (vdi) as "Pre Processing..." in Simulation Control ("Simulation control" > "Pre/Post" tab), while to get a constant value into the Vensim model, I should have gone to "Simulation Control" > "Changes" tab and loaded the vdi file in "Load changes from...". In this case, the constant value is going to be read from the respective table in database, and any number you enter as the value for the constant in your Vensim model (C1 in the attached model) will be changed.

<< I added a video about this topic, please check this post: http://www.ventanasystems.co.uk/forum/v ... 513#p16555 >>

Thanks,
M.J.
Last edited by Mohammad Jalali on Thu Mar 22, 2012 4:35 am, edited 1 time in total.
tomfid
Administrator
Posts: 3808
Joined: Wed May 24, 2006 4:54 am

Re: ODBC Problems (Connecting Vensim to MS Access)

Post by tomfid »

Glad you worked it out. I'm guessing that your copy of Vensim is not the latest; .vdi files should work in the pre-processing step, but there was a bug in the dialog processing that prevented that, fixed fairly recently (5.11). Putting the .vdi in the Changes field as you did is a valid solution though; glad you worked it out.

Tom
Mohammad Jalali
Member
Posts: 20
Joined: Wed Mar 07, 2012 10:50 pm
Vensim version: DSS

Re: ODBC Problems (Connecting Vensim to MS Access)

Post by Mohammad Jalali »

Thank you! My DSS is version 5.11A for Windows. Isn't it the last one?

M.J.
Administrator
Super Administrator
Posts: 4589
Joined: Wed Mar 05, 2003 3:10 am

Re: ODBC Problems (Connecting Vensim to MS Access)

Post by Administrator »

5.11a is the latest version.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
tomfid
Administrator
Posts: 3808
Joined: Wed May 24, 2006 4:54 am

Re: ODBC Problems (Connecting Vensim to MS Access)

Post by tomfid »

Hmm ... that should be fine then. I'll do some testing to be sure everything is working right.

Tom
Mohammad Jalali
Member
Posts: 20
Joined: Wed Mar 07, 2012 10:50 pm
Vensim version: DSS

Connecting Vensim to MS Access with ODBC (Tutorial video)

Post by Mohammad Jalali »

I have recorded a video about connecting Vensim to MS Access with ODBC. Examples presented in this video are: 1) How to read variables, constants, lookups, and subscripts from a database, and 2) How to write simulation output into a database. I have tried to use very simple examples and explained all details so everyone should be able to replicate the examples.

Check it out here: http://www.youtube.com/watch?v=JmCr9Dr5Gw8

Note: more information on this topic can be found in Vensim's Help > DSS Reference Supplement > Chapter 14.

Best,
M.J.
tomfid
Administrator
Posts: 3808
Joined: Wed May 24, 2006 4:54 am

Re: ODBC Problems (Connecting Vensim to MS Access)

Post by tomfid »

Mohammad Jalali
Member
Posts: 20
Joined: Wed Mar 07, 2012 10:50 pm
Vensim version: DSS

Re: ODBC Problems (Connecting Vensim to MS Access)

Post by Mohammad Jalali »

Thank you!

M.J.
Post Reply