Reading text file as code

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Reading text file as code

Post by kpassaur » Mon Nov 30, 2009 11:13 am

This is hard to explain but I will try my best.

I have a script that reads a database file and it works properly with this line.

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\temp;Extended Properties='text;HDR=NO;FMT=Delimited;Option=1'

I want the user to be able to edit it so I saved it as a text file so it could be read. It is read correctly but when the program is run it fails so in debuging I entered this in my code:

MDL>ConStr
Let>ConStr=Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%datapath%;Extended Properties='text;HDR=NO;FMT=Delimited;Option=1'
MDL>ConStr

and this was returned:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%datapath%;Extended Properties='text;HDR=NO;FMT=Delimited;Option=1'
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\temp;Extended Properties='text;HDR=NO;FMT=Delimited;Option=1'

What I want to do is have %datapath% updated to conatin the value in the variable %datapath% not the literal %datapath%

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Figured it out

Post by kpassaur » Mon Nov 30, 2009 11:52 am

I got it running by the following:

Let>VAREXPLICIT=1
//MDL>%ConStr%
//Let>ConStr=Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%datapath%;Extended Properties='text;HDR=NO;FMT=Delimited;Option=1'
//MDL>ConStr


DBConnect>%ConStr%,dbH
Let>SQL=select * from %datafile%
Let>VAREXPLICIT=0
DBQuery>dbH,SQL,fields,num_recs,num_fields

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts