
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hello COBOL community,
I actually work on a project with this configuration:
- Visual Studio 2017
- Visual Cobol 4.0
-SQL Server 2014 and SSMS 2017
- Native project
I actually have some programs with access to a database. I use a "Connect" statement with parameters such as "Trusted_Connection","Database","factory","server".
My question is: is it possible to include all those parameters with the ADO connection assistant? I tried to configure one but when I use my exec sql statements, I have an SQLcode error.
The goal is to epurate the code of the procedure division and have a COBOL-like program.
Thank you for your answers and have a wonderful week.
Sebastien.
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Native programs/projects using ODBC connections and managed .NET programs/projects use ADO connections.
If you are doing a connect from a native application then you would create your DSN using the ODBC Datasource Administrator tool available from the Micro Focus Visual COBOL group on the start menu under Data Tools-->Data Connections. You must choose the version of the tool that matches the bitism of your project either 32-bit for x86 or 64-bit for x64.
The name that you give to your DSN in this tool is the name that you would use in the CONNECT statement.
Example:
EXEC SQL CONNECT TO dsnname END-EXEC
If you are using managed code then you create the DSN using the ADO Connection Editor and likewise use its name in the EXEC SQL CONNECT statement.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
When the connection fails in the EXEC SQL CONNECT statement what is the returned SQLCODE and error message?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
When I test the connection it is successful.
I have the SQLCode "-0019702" with the SQLState" IM001" on all operations (Select, Update, Insert, Delete).
Have a nice day.
Sebastien.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Native programs/projects using ODBC connections and managed .NET programs/projects use ADO connections.
If you are doing a connect from a native application then you would create your DSN using the ODBC Datasource Administrator tool available from the Micro Focus Visual COBOL group on the start menu under Data Tools-->Data Connections. You must choose the version of the tool that matches the bitism of your project either 32-bit for x86 or 64-bit for x64.
The name that you give to your DSN in this tool is the name that you would use in the CONNECT statement.
Example:
EXEC SQL CONNECT TO dsnname END-EXEC
If you are using managed code then you create the DSN using the ADO Connection Editor and likewise use its name in the EXEC SQL CONNECT statement.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Just for information is there a way to make the MySQL connection "native" when I create a project without this CONNECT statement ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
It is highly recommended that you do include a CONNECT statement in your program.
There is a directive called SQL(INIT) that can be used in conjunction with the DB and PASS directives that will cause the precompiler to generate this connect code for you but this is dangerous as it exposes your program to having the user credentials appear as clear text within the program itself.
Docs for INIT directive can be found here:
It is not required that you create a connection with a DSN name within one of the editors. This is simply for ease of use and so that the credentials are stored outside of the program. You can use a format 6 CONNECT statement which allows you to pass in a complete connection string instead of using a DSN name.
Examples of this are in the SQL documentation here

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content