Highlighted
Absent Member.
Absent Member.
4686 views

visual cobol sql connection string

Jump to solution

[Migrated content. Thread originally posted on 28 September 2011]

Hello everybody,


We are trying to move our data files to an sql database environment, but we are having problem to create the connection with the sql server database.

Someone can giveme an example to do it, please?

Thanks
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: visual cobol sql connection string

Jump to solution
Are you creating a managed code project or a native project?

For managed code you should use directive SQL(DBMAN=ADO) and then create the ADO Connection using the Connection Editor as follows:

Navigate to the Start Menu->All Programs->Micro Focus Visual COBOL 2010->Visual COBOL Data Connections->ADO.NET Connection Editor
- Start the Connection Editor. You need to create a new connection and give it the name that you will reference in CONNECT statement. In this example we will create a connection to the Northwind database assuming that this is installed in your SQL Server instance.
- Click the radio buttons for 32-bit or 64-bit and User or System and choose the version of the .NET framework to use.

Example: System Framework 4.0 32-bit.

- Click the Add button to create a new connection.
- Select the Provider tab and choose SqlClient Data Provider and in Data Source Name enter the name of the connection that you will reference in the CONNECT statement, for Example NWConnect and press Next.
- Most of the options can remain at their default settings.
- The following options need to be changed:
Data Source = name of your SQL Server instance e.g, COMPNAME\SQLEXPRESS or (local)
Initial Catalog=Northwind
Integrated Security= True
Then press Save and test the connection.

In your program you would connect using:

EXEC SQL CONNECT NWConnect END-EXEC


If you are creating a native project then you should set SQL(DBMAN=ODBC) and then use the ODBC Data Source Administrator to create a new ODBC DSN which can be launched as follows:

Navigate to the Start Menu->All Programs->Micro Focus Visual COBOL 2010->Visual COBOL Data Connections->ODBC Data Source Administrator either 32-bit or 64-bit depending on what you are using.
- Start the Administrator. You need to create a new System DSN and fill in the appropriate options for your SQL Server instance. The DSN name will be the name you reference in the CONNECT statement.


Hope this helps...

View solution in original post

0 Likes
4 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: visual cobol sql connection string

Jump to solution
Are you creating a managed code project or a native project?

For managed code you should use directive SQL(DBMAN=ADO) and then create the ADO Connection using the Connection Editor as follows:

Navigate to the Start Menu->All Programs->Micro Focus Visual COBOL 2010->Visual COBOL Data Connections->ADO.NET Connection Editor
- Start the Connection Editor. You need to create a new connection and give it the name that you will reference in CONNECT statement. In this example we will create a connection to the Northwind database assuming that this is installed in your SQL Server instance.
- Click the radio buttons for 32-bit or 64-bit and User or System and choose the version of the .NET framework to use.

Example: System Framework 4.0 32-bit.

- Click the Add button to create a new connection.
- Select the Provider tab and choose SqlClient Data Provider and in Data Source Name enter the name of the connection that you will reference in the CONNECT statement, for Example NWConnect and press Next.
- Most of the options can remain at their default settings.
- The following options need to be changed:
Data Source = name of your SQL Server instance e.g, COMPNAME\SQLEXPRESS or (local)
Initial Catalog=Northwind
Integrated Security= True
Then press Save and test the connection.

In your program you would connect using:

EXEC SQL CONNECT NWConnect END-EXEC


If you are creating a native project then you should set SQL(DBMAN=ODBC) and then use the ODBC Data Source Administrator to create a new ODBC DSN which can be launched as follows:

Navigate to the Start Menu->All Programs->Micro Focus Visual COBOL 2010->Visual COBOL Data Connections->ODBC Data Source Administrator either 32-bit or 64-bit depending on what you are using.
- Start the Administrator. You need to create a new System DSN and fill in the appropriate options for your SQL Server instance. The DSN name will be the name you reference in the CONNECT statement.


Hope this helps...

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: visual cobol sql connection string

Jump to solution
i have a script which you can use that creates an odbc connection on the fly.

do you want me to post it on here?
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: visual cobol sql connection string

Jump to solution
Neil Willby originally wrote:
i have a script which you can use that creates an odbc connection on the fly.

do you want me to post it on here?


Yes Neil, Please post it, that is a good way to do it,

Thanks


0 Likes
Highlighted
Absent Member.
Absent Member.

RE: visual cobol sql connection string

Jump to solution
Chris Glazier originally wrote:
Are you creating a managed code project or a native project?

For managed code you should use directive SQL(DBMAN=ADO) and then create the ADO Connection using the Connection Editor as follows:

Navigate to the Start Menu->All Programs->Micro Focus Visual COBOL 2010->Visual COBOL Data Connections->ADO.NET Connection Editor
- Start the Connection Editor. You need to create a new connection and give it the name that you will reference in CONNECT statement. In this example we will create a connection to the Northwind database assuming that this is installed in your SQL Server instance.
- Click the radio buttons for 32-bit or 64-bit and User or System and choose the version of the .NET framework to use.

Example: System Framework 4.0 32-bit.

- Click the Add button to create a new connection.
- Select the Provider tab and choose SqlClient Data Provider and in Data Source Name enter the name of the connection that you will reference in the CONNECT statement, for Example NWConnect and press Next.
- Most of the options can remain at their default settings.
- The following options need to be changed:
Data Source = name of your SQL Server instance e.g, COMPNAME\SQLEXPRESS or (local)
Initial Catalog=Northwind
Integrated Security= True
Then press Save and test the connection.

In your program you would connect using:

EXEC SQL CONNECT NWConnect END-EXEC


If you are creating a native project then you should set SQL(DBMAN=ODBC) and then use the ODBC Data Source Administrator to create a new ODBC DSN which can be launched as follows:

Navigate to the Start Menu->All Programs->Micro Focus Visual COBOL 2010->Visual COBOL Data Connections->ODBC Data Source Administrator either 32-bit or 64-bit depending on what you are using.
- Start the Administrator. You need to create a new System DSN and fill in the appropriate options for your SQL Server instance. The DSN name will be the name you reference in the CONNECT statement.


Hope this helps...



Thanks Chris, It has been exelent help,

Thanks again

0 Likes
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.