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!!
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