New Member.

Cobol and Informix interaction: specify settings in Connection String


I'm having some problems with my database connection. I'm using Visual COBOL v4.0 (with Visual Studio 2017) and my database is Informix 3.5.

I'm using Micro Focus ADO.NET Connection Editor to create an ADO.NET Data Source, with OpenESQL as ESQL Preprocessor.

The ESQL connection statement from my COBOL program is:

connect to "CobolInformix"

(obviously "CobolInformix" is the already configured DSN).

It works flawlessly until I am working on "standard" databases, allowing program to receive and write data.
But when I try to get data from databases with specific connection settings (such as db_locale=en_us.1252 or unicode=true), I got an error ("Illegal use of host variables") because I can't set that properties.

In another application, I'm using C# to access to the same database with a connection string similar to this: Ifxoledbc.2;Data Source=myDatabase@myServer;Persist Security Info=False;User ID=user;Password=*****;Pooling=false;db_locale=en_us.1252;client_locale=en_us.1252;.

Is there a way to  connect to a database in Visual Cobol specifying the connection string? Or I am forced to use the Micro Focus ADO.NET Connection Editor, in which I cannot specify that parameters?


I'm not very good with english, I hope you will understand me. Thank you in advance!!

Piero B.

1 Reply
Micro Focus Expert
Micro Focus Expert

You can use what is called a Format 6 Connect statement which allows you to specify a connection string and does not require the ADO Connection Editor.

Documentation for this can be found here:

Example for SQL Server:

   declare myconnect as string =
     'Data Source=SERVER1;Initial Catalog=Northwnd;Integrated Security=True;'
        & 'MultipleActiveResultSets=True;Factory=System.Data.SqlClient;' 

   exec sql connect using :myconnect end-exec
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.