Page 1 of 1

ODBC Problems (Connecting Vensim to MS Access)

Posted: Wed Mar 07, 2012 10:52 pm
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.

Re: ODBC Problems (Connecting Vensim to MS Access)

Posted: Wed Mar 07, 2012 10:57 pm
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.

Re: ODBC Problems (Connecting Vensim to MS Access)

Posted: Thu Mar 08, 2012 2:42 pm
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

Re: ODBC Problems (Connecting Vensim to MS Access)

Posted: Fri Mar 09, 2012 12:42 am
by Mohammad Jalali
Thank you! My DSS is version 5.11A for Windows. Isn't it the last one?

M.J.

Re: ODBC Problems (Connecting Vensim to MS Access)

Posted: Fri Mar 09, 2012 9:50 am
by Administrator
5.11a is the latest version.

Re: ODBC Problems (Connecting Vensim to MS Access)

Posted: Sun Mar 11, 2012 3:25 pm
by tomfid
Hmm ... that should be fine then. I'll do some testing to be sure everything is working right.

Tom

Connecting Vensim to MS Access with ODBC (Tutorial video)

Posted: Wed Mar 21, 2012 1:42 am
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.

Re: ODBC Problems (Connecting Vensim to MS Access)

Posted: Mon Mar 26, 2012 11:11 pm
by tomfid

Re: ODBC Problems (Connecting Vensim to MS Access)

Posted: Mon Mar 26, 2012 11:48 pm
by Mohammad Jalali
Thank you!

M.J.