Re: Fujitsu NetCobol 8.0



Jude wrote:
Thanks for the responses!



string "Driver={MySQL ODBC 3.51 Driver};Server=judehome;" delimited
by size "Database=avsdb;User=avssys;" delimited by size
"Password=avssys;Option=3;" delimited by size into connString.
exec sql
Connect to :connString
end-exec

produces the following err:
JMP0371I-U [PID:000009D0 TID:00000C20] ENVIRONMENT INFORMATION FILE
ERROR TO PERFORM SQL. '@ODBC_Inf'. PGM=MAINFORM. LINE=98

Not sure exactly what this means.

You cannot use a connection string in the way you have shown and expect it
to work. The CONNECT is looking for a simple string to recognise the
connection by: MyDB1 or something like that. (I posted an example here a
while back which used an instance stamp... point is it is has no meaning...
it is just a "connection symbol".)

Fujitsu has been told to use an SQL information file and the file is not
present. You need to change your COBOL85.CBR file and the ODBC.inf file it
points at. Remove the SQLinfo line from COBOL85.CBR.

You also need to instantiate an instance of ADO before it can recognise your
connection string and result set.

more below...



"Pete Dashwood" <dashwood@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:6vgvloFjureaU1@xxxxxxxxxxxxxxxxxxxxx
Jude wrote:
Hi,

Any Fujitsu NetCobol / PowerCobol users here?

I'm using PowerCobol 8.0 and MySql 5.1 with MySQL ODBC 3.51. To
access the database I create a user or system DSN and this works.
But what I would really like to not have to create the DSN and
connect DSNless, like I do in c# and vb.net. Does anyone here know
how to do this in PC?
Thanks!

Use the ADO control provided in PowerCOBOL, or simply instatiate ADO
or DAO through Automation (COM). It's easy and it works very well
with Fujitsu COBOL.

...but you didn't, did you? :-)

How did you expect it to work?

Fujitsu supports ONLY ODBC access directly from their COBOL

If you want the power of non-ODBC access, you must use the Component Object
Model (COM). Bear in mind that the rest of the computer community use
components as a matter of course and they EXPECT to have object instances
of components doing the work for them. Only old-time COBOL programmers (OK,
maybe PL/1 too...) see components and objects as the mark of Satan... :-)

I have used MySQL from Fujitsu COBOL (and found it to be an excellent RDB)
but ONLY with the ODBC driver they provide, via the external environment
information files. However, I am pretty confident you can do this with ADO
and, because you had a go and posted the code here, here's an untested
sample that should be close to what you need:
....
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
REPOSITORY.
CLASS COM AS "*COM".

....
01 ADO-connection pic x(128) value "ADODB.Connection".
01 ADO-ResultSet pic x(128) value "ADODB.Recordset".
01 OBJ-ADO OBJECT REFERENCE COM.
01 OBJ-RS OBJECT REFERENCE COM.
01 ADO-open-string pic x(256) value spaces.
01 SQL-string pic x(256) value spaces.
01 ADO-RS-cursor-type pic s9(4) comp-5.
88 adOpenDynamic value 2.
01 ADO-RS-lock-type pic s9(4) comp-5.
88 adLockOptimistic value 3.
....
move spaces to ADO-open-string
string "DRIVER={MySQL ODBC 3.51
Driver};SERVER=judehome;"
delimited by size
"DATABASE=avsdb;UID=root;"
delimited by size
"PWD=avssys;OPTION=35;"
delimited by size
into ADO-open-string
end-string
*>
*> instantiate connection and resultset objects...
*>
invoke COM "CREATE-OBJECT"
using ADO-connection
returning OBJ-ADO
end-invoke
invoke COM "CREATE-OBJECT"
using ADO-ResultSet
returning OBJ-RS
end-invoke
*>
*> Step through the above with the debugger and make sure that
OBJ-ADO and OBJ-RS
*> have been loaded with an instance address (not NULL). If there is
a problem with your
*> system (like, ADO is not installed or up to date...) you SHOULD
get a COM abend.
*> you can trap this with the special COM-EXCEPTION class (Check your
Fujitsu docs...)
*>
*> all set, let's connect...
*>
invoke OBJ-ADO "open"
using ADO-open-string
end-invoke
*>
*> It will abend if there is a problem. See above. (Abends are VERY
rare, and the Fujitsu COM Class
*> generally passes back good information from the Automation
interface.)
*>

There are a number of ways you can choose to process.

The 2 main ones are using either a Command object or the Resultset object.

(As this is quick free help, I won't cover the command object;
recordset/resultset processing is the most popular anyway...)

If you intend to use the recordset/resultset processing you will need to
invoke methods on the RS object.

This can be a bit tricky as there are quite a few possibilities. To get you
started, here's an example...


*> set up your query....
move "SELECT model, colour FROM showroom WHERE marque
= 'Yugo'"
to SQL-string
set adOpenDynamic to TRUE
set adLockOptimistic to TRUE

*> get the result set...
invoke OBJ-RS "Open"
using SQL-string,
ADO-OBJ,
ADO-RS-cursor-type,
ADO-RS-lock-type
end-invoke
Process it using the various commands available until it returns EOF...

I strongly recommend you take a look at the ADO command set and do a quick
tutorial on ADO processing.

W3C schools are excellent.

http://www.w3schools.com/

Check out their "learn ADO" option.

HTH,

Pete.
--
"I used to write COBOL...now I can do anything."


.



Relevant Pages

  • Re: connection strings question
    ... First of all ADO does not work with ODBC drivers directly and in a case ... In a case of SQL Server, your connection string would look like ... If you are trying to open connection once and keep it during life of the ...
    (microsoft.public.vb.database.ado)
  • Re: Reading Access 2003 (.mdb) tables/queries with D5-Pro ?
    ... If you don't have the ADO components, ... // build connection string and create ADO connection object ... rs.Open(sql, cnn, adOpenForwardOnly, adLockReadOnly, 0); ...
    (comp.lang.pascal.delphi.misc)
  • RE: Access 2007 Connection String
    ... that if you are using ADO to connect to the CURRENT ... CurrentProject.Connection as the connection and not a normal ADO connection ... Utter Access VIP ... anyone tell me the provider text and the rest of the connection string ...
    (microsoft.public.access.externaldata)
  • Re: RDO Connection <--> ADO Connection
    ... modify the connection string so it can be passed between ADO and RDO. ...
    (microsoft.public.data.ado)
  • Re: C++ support for ADO
    ... TESTHR(pConn.CreateInstance(__uuidof(Connection))); ... In answer to your question I'm interested in ADO not the ADO.net. ... data classes for working with ADO/OLE DB. ... You can also use the OLE SDK. ...
    (microsoft.public.data.ado)