Skip to main content

Hello, I am trying by all means to establish a connection to a SQL Server database, I supposedly connect but cannot see the data in a table.

These are the errors:

connection to the database established
Error: It is not possible to Access the Province Table
Error code: -00000000208
Description Error: The object name 'province' is not valid

Please can someone help me.

Thank you.


#VisualCOBOL
#SQL

Hello, I am trying by all means to establish a connection to a SQL Server database, I supposedly connect but cannot see the data in a table.

These are the errors:

connection to the database established
Error: It is not possible to Access the Province Table
Error code: -00000000208
Description Error: The object name 'province' is not valid

Please can someone help me.

Thank you.


#VisualCOBOL
#SQL

This is so easy to connect to a mssql server from cobol program!
Can you publish the cobol and sql commands here?

*> connect format 1
MOVE 'servername' TO svr
MOVE 'username.password' TO usr
EXEC SQL CONNECT TO :svr USER :usr END-EXEC
*> connect format 2
EXEC SQL CONNECT 'username.password' USING 'servername'
END-EXEC
*> connect format 3
EXEC SQL CONNECT WITH PROMPT END-EXEC
*> connect format 4
EXEC SQL CONNECT RESET END-EXEC
*> connect format 5
EXEC SQL CONNECT USING 'FileDSN=Oracle8;PWD=tiger' END-EXEC
*> connect format 6
* 01 connectString PIC X(72) value
* 'DRIVER={Microsoft Excel Driver (*.xls)};'
* &'DBQ=c:\\demo\\demo.xls;'
* &'DRIVERID=22'.
EXEC SQL CONNECT USING connectString END-EXEC

cg


Hello, I am trying by all means to establish a connection to a SQL Server database, I supposedly connect but cannot see the data in a table.

These are the errors:

connection to the database established
Error: It is not possible to Access the Province Table
Error code: -00000000208
Description Error: The object name 'province' is not valid

Please can someone help me.

Thank you.


#VisualCOBOL
#SQL

What is the collation property of your database? Is it case sensitive?

How is the Table name in your database displayed in SQL Server management studio? For example:  "province", "Province", or "PROVINCE"? 

Does the table name in your SQL Query match exactly what is displayed in SQL Server"?


Hello, I am trying by all means to establish a connection to a SQL Server database, I supposedly connect but cannot see the data in a table.

These are the errors:

connection to the database established
Error: It is not possible to Access the Province Table
Error code: -00000000208
Description Error: The object name 'province' is not valid

Please can someone help me.

Thank you.


#VisualCOBOL
#SQL

On what platform and OS are you running? Is this Windows or Linux?
Which product are you using, Visual COBOL for Visual Studio or Visual COBOL for Eclipse, DevHub, etc.?
If it is on Windows, you should be able to test the connection directly from the ODBC Administrator where you setup your ODBC DSN.

What does your SELECT statement look like for the province table? Perhaps you do not have access to that table in the schema you are using.

If on Windows, you should be able to test your statements using the OpenESQL Assistant also. This is available from the View-->Micro Focus SQL Tools menu item in Visual Studio. This will allow you to connect to the database and build a select statement and test it.


This is so easy to connect to a mssql server from cobol program!
Can you publish the cobol and sql commands here?

*> connect format 1
MOVE 'servername' TO svr
MOVE 'username.password' TO usr
EXEC SQL CONNECT TO :svr USER :usr END-EXEC
*> connect format 2
EXEC SQL CONNECT 'username.password' USING 'servername'
END-EXEC
*> connect format 3
EXEC SQL CONNECT WITH PROMPT END-EXEC
*> connect format 4
EXEC SQL CONNECT RESET END-EXEC
*> connect format 5
EXEC SQL CONNECT USING 'FileDSN=Oracle8;PWD=tiger' END-EXEC
*> connect format 6
* 01 connectString PIC X(72) value
* 'DRIVER={Microsoft Excel Driver (*.xls)};'
* &'DBQ=c:\\demo\\demo.xls;'
* &'DRIVERID=22'.
EXEC SQL CONNECT USING connectString END-EXEC

cg

Hello!!

I am trying to connect COBOL Visual with SQL Server, I cannot find a possible way, I have tried several ways as you indicate, but I have not been able to.

$SET SQL(DBMAN=ODBC) sourceformat(variable)
IDENTIFICATION DIVISION.
program-id callODBCsql.

data division.
working-storage section.
EXEC SQL INCLUDE SQLCA END-EXEC.
01 SQLCA.
05 SQLCAID PIC X(8) VALUE "SQLCA ".
05 SQLCABC PIC S9(9) COMP-5 VALUE 136.
05 SQLCODE PIC S9(9) COMP-5 VALUE 0.
05 SQLERRM.
49 SQLERRML PIC S9(4) COMP-5.
49 SQLERRMC PIC X(70).
05 SQLERRP PIC X(8).
05 SQLERRD PIC S9(9) COMP-5 OCCURS 6 VALUE 0.
05 SQLWARN.
10 SQLWARN0 PIC X.
10 SQLWARN1 PIC X.
10 SQLWARN2 PIC X.
10 SQLWARN3 PIC X.
10 SQLWARN4 PIC X.
10 SQLWARN5 PIC X.
10 SQLWARN6 PIC X.
10 SQLWARN7 PIC X.
05 SQLEXT.
10 SQLWARN8 PIC X.
10 SQLWARN9 PIC X.
10 SQLWARN10 PIC X.
10 SQLWARNA REDEFINES SQLWARN10 PIC X .
05 SQLSTATE PIC X(5).

EXEC SQL INCLUDE provinces END-EXEC

01 DCProvincias.
05 provincecod pic N(2)
USAGE NATIONAL.
05 provincenam pic N(20)
USAGE NATIONAL.

procedure division.
main-para.

EXEC SQL
CONNECT TO 'ODBCSQLSERVER'
END-EXEC.

if sqlcode not = 0
   display "Error: It is not possible to establish a connection to the DB."
  display "Error Code : " sqlcode
  display "Description Error: " sqlerrmc
  goback
ELSE
   display "Connection to the established database" 
   end-if.

move 10001 to provincecod
EXEC SQL
SELECT
provincecode, provincename
INTO
:provincecod, :provincenam
FROM provinces
WHERE provincecode = :provincecod
END-EXEC

if sqlcode not = 0
display
"Error: It is not possible to access the province table"
display "Error Code : " sqlcode
display "Description Error: " sqlerrmc
goback
else
display "Province Code : " provincecod
display "Province Name : " provincenam
end-if
EXEC SQL
DISCONNECT CURRENT
END-EXEC
goback.   

TABLE

Connection to the established database
Error: It is not possible to access the province table
Error Code : -0000000208
Description Error: The object name 'provinces' is not valid.
Press a key to continue . . .


Hello!!

I am trying to connect COBOL Visual with SQL Server, I cannot find a possible way, I have tried several ways as you indicate, but I have not been able to.

$SET SQL(DBMAN=ODBC) sourceformat(variable)
IDENTIFICATION DIVISION.
program-id callODBCsql.

data division.
working-storage section.
EXEC SQL INCLUDE SQLCA END-EXEC.
01 SQLCA.
05 SQLCAID PIC X(8) VALUE "SQLCA ".
05 SQLCABC PIC S9(9) COMP-5 VALUE 136.
05 SQLCODE PIC S9(9) COMP-5 VALUE 0.
05 SQLERRM.
49 SQLERRML PIC S9(4) COMP-5.
49 SQLERRMC PIC X(70).
05 SQLERRP PIC X(8).
05 SQLERRD PIC S9(9) COMP-5 OCCURS 6 VALUE 0.
05 SQLWARN.
10 SQLWARN0 PIC X.
10 SQLWARN1 PIC X.
10 SQLWARN2 PIC X.
10 SQLWARN3 PIC X.
10 SQLWARN4 PIC X.
10 SQLWARN5 PIC X.
10 SQLWARN6 PIC X.
10 SQLWARN7 PIC X.
05 SQLEXT.
10 SQLWARN8 PIC X.
10 SQLWARN9 PIC X.
10 SQLWARN10 PIC X.
10 SQLWARNA REDEFINES SQLWARN10 PIC X .
05 SQLSTATE PIC X(5).

EXEC SQL INCLUDE provinces END-EXEC

01 DCProvincias.
05 provincecod pic N(2)
USAGE NATIONAL.
05 provincenam pic N(20)
USAGE NATIONAL.

procedure division.
main-para.

EXEC SQL
CONNECT TO 'ODBCSQLSERVER'
END-EXEC.

if sqlcode not = 0
   display "Error: It is not possible to establish a connection to the DB."
  display "Error Code : " sqlcode
  display "Description Error: " sqlerrmc
  goback
ELSE
   display "Connection to the established database" 
   end-if.

move 10001 to provincecod
EXEC SQL
SELECT
provincecode, provincename
INTO
:provincecod, :provincenam
FROM provinces
WHERE provincecode = :provincecod
END-EXEC

if sqlcode not = 0
display
"Error: It is not possible to access the province table"
display "Error Code : " sqlcode
display "Description Error: " sqlerrmc
goback
else
display "Province Code : " provincecod
display "Province Name : " provincenam
end-if
EXEC SQL
DISCONNECT CURRENT
END-EXEC
goback.   

TABLE

Connection to the established database
Error: It is not possible to access the province table
Error Code : -0000000208
Description Error: The object name 'provinces' is not valid.
Press a key to continue . . .



It appears to be connecting just fine it is the name of the table that isn't being recognized.

Try the following:

Assuming you are using Visual Studio, from the Visual Studio View menu select Micro Focus SQL Tools and then OpenESQL Assistant. Does your connection show in the list? If it does click on it and it should show you available tables. Select the province table and generate a singleton query for it. What does the source code look like for the query?

You can also look at the host variable descriptions under the Details tab and generate a copybook for them by selecting the Auxiliary Code tab and selecting Host Variables. You can also run the query from within OpenESQL Assistant by clicking on the Run Query icon on the top left corner of the OpenESQL Assistant window.


It appears to be connecting just fine it is the name of the table that isn't being recognized.

Try the following:

Assuming you are using Visual Studio, from the Visual Studio View menu select Micro Focus SQL Tools and then OpenESQL Assistant. Does your connection show in the list? If it does click on it and it should show you available tables. Select the province table and generate a singleton query for it. What does the source code look like for the query?

You can also look at the host variable descriptions under the Details tab and generate a copybook for them by selecting the Auxiliary Code tab and selecting Host Variables. You can also run the query from within OpenESQL Assistant by clicking on the Run Query icon on the top left corner of the OpenESQL Assistant window.

Hi Chris, thanks for responding;
I am using Visual Studio 2022, in the View menu of Visual Studio the Micro Focus SQL Tools option does not appear, therefore it cannot do what it asks me to do, if it is not there, could it be that the installation of Visual Studio is wrong? How difficult this whole connection with SQL thing is. I greatly appreciate the effort you make as a collaborator, thank you very much, I don't know if I will ever be able to establish this connection so that I can continue learning Visual Cobol with SQL.


Hi Chris, thanks for responding;
I am using Visual Studio 2022, in the View menu of Visual Studio the Micro Focus SQL Tools option does not appear, therefore it cannot do what it asks me to do, if it is not there, could it be that the installation of Visual Studio is wrong? How difficult this whole connection with SQL thing is. I greatly appreciate the effort you make as a collaborator, thank you very much, I don't know if I will ever be able to establish this connection so that I can continue learning Visual Cobol with SQL.

It sounds as if maybe the install is corrupt if you dont see that option under the View menu.

Please perform the steps in the documentation here,

It should look like this


It sounds as if maybe the install is corrupt if you dont see that option under the View menu.

Please perform the steps in the documentation here,

It should look like this

Hello Chris, I found the option but tools and options, here is OpenESQL Assistant, the connection does not appear. I have Visual Studio 2022 in Spanish.


Hello Chris, I found the option but tools and options, here is OpenESQL Assistant, the connection does not appear. I have Visual Studio 2022 in Spanish.

The screen shots you are showing me are where the options for OpenESQL Assistant are set not where it is started from.

I found this problem in a previous post and it has to do with Visual Studio running with a non-English language. The SQL Tools menu item only appears if English is the language. Can you try setting your language to English just while you are using OpenESQL Assistant and see if the option shows up?


The screen shots you are showing me are where the options for OpenESQL Assistant are set not where it is started from.

I found this problem in a previous post and it has to do with Visual Studio running with a non-English language. The SQL Tools menu item only appears if English is the language. Can you try setting your language to English just while you are using OpenESQL Assistant and see if the option shows up?

Ok.


The screen shots you are showing me are where the options for OpenESQL Assistant are set not where it is started from.

I found this problem in a previous post and it has to do with Visual Studio running with a non-English language. The SQL Tools menu item only appears if English is the language. Can you try setting your language to English just while you are using OpenESQL Assistant and see if the option shows up?

Hello Chris, you are right, in Spanish Visual Studio works differently. I have changed the language, now the OpenESQL Assistant appears, after changing the language, I did a MySql connection test, I was able to do a Select and an insert from the code and it worked very well, the next day it stopped working, it does not occur no errors, the same thing happens with the connection with SQL server, in OpenESQL the DB and the tables appear, execute query, insert, update, delete and it works very well, but in the code it does not work, it does not search for anything.


Hello Chris, you are right, in Spanish Visual Studio works differently. I have changed the language, now the OpenESQL Assistant appears, after changing the language, I did a MySql connection test, I was able to do a Select and an insert from the code and it worked very well, the next day it stopped working, it does not occur no errors, the same thing happens with the connection with SQL server, in OpenESQL the DB and the tables appear, execute query, insert, update, delete and it works very well, but in the code it does not work, it does not search for anything.

Are you copying the code from OpenESQL Assistant directly into your program?
After the select what is the value of SQLCODE?

In the screen shot here you are generating code for a singleton select which means it will only return one row of data. A singleton select should have a where clause on it to limit the search. I think what you are looking for is a cursor select which can also be generated by the Assistant.

This will generate code which will define the cursor, open the cursor and then, in a loop, fetch all of the rows.

If it works in the Assistant then it should work in the program if you are using the same DSN to connect.