DSN-Less Connections with SQAPL

General APL language issues

DSN-Less Connections with SQAPL

Postby paulmansour on Tue Feb 24, 2015 4:05 am

With SQAPL, is there a way to connect to an ODBC data source without having a DSN predefined?

For example, I would like to use a connection string like:

      Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=C:\mydatabase.accdb;


I know I can use a generic MS Access DSN that allows me to specify the Dbq parameter in the DriverOptions parameter of SQA.Connect, so the file name itself can be set dynamically, but this still requires a DSN.'

I would like to do:

      SQA.Connect 'C1 '' ('DriverOptions' 'Driver=xxx; etc')


... fully specifying everything in the DriverOptions parameter at runtime.

If something like this cannot be done, is it because of a limitation of ODBC or of SQAPL?
paulmansour
 
Posts: 375
Joined: Fri Oct 03, 2008 4:14 pm

Re: DSN-Less Connections with SQAPL

Postby Vince|Dyalog on Wed Feb 25, 2015 12:52 pm

Hi Paul,

I've asked Bjørn about this.

It is mentioned in a footnote in the SQAPL reference guide which says this:

It is possible to connect to databases for which there is no pre-defined data source – see the description of the SQA.Connect function, in particular the DriverOptions parameter. Also see the warning on the next page regarding 32- vs 64-bit ODBC drivers under Windows.

Bjørn gave me an example:

      do←'DRIVER={Microsoft Access Driver (*.mdb)};DBQ=C:\download\test32.mdb;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;UID=admin;'

SQA.Connect 'C1' '' ('DriverOptions' do)
0


SQA.DSN '.'
can give you a hint for driver names.

Please note that the name of the driver is not universal it changes with language and version.

Regards,

Vince
Vince|Dyalog
 
Posts: 355
Joined: Wed Oct 01, 2008 9:39 am

Re: DSN-Less Connections with SQAPL

Postby paulmansour on Wed Feb 25, 2015 1:07 pm

Vince,

Ok, good to know this should work. This is almost exactly what I tried but couldn't get it to work. I'll tinker around some more and report back. Thanks
paulmansour
 
Posts: 375
Joined: Fri Oct 03, 2008 4:14 pm

Re: DSN-Less Connections with SQAPL

Postby Brian|Dyalog on Thu Feb 26, 2015 6:24 pm

We use DSN-less connections in the MiServer samples (they're in the Datasources.xml configuration file).

One invaluable resource I've discovered is http://www.connectionstrings.com/.
It has information on connection strings for just about every database that ever existed.
User avatar
Brian|Dyalog
 
Posts: 112
Joined: Thu Nov 26, 2009 4:02 pm
Location: West Henrietta, NY

Re: DSN-Less Connections with SQAPL

Postby paulmansour on Fri Feb 27, 2015 5:58 pm

Vince: Ok, got it to work, must have just typed something wrong before. Thanks.
Brian: thanks. Yes, I was aware of connectionstrings.com... very useful!
paulmansour
 
Posts: 375
Joined: Fri Oct 03, 2008 4:14 pm


Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest