Highlighted
Absent Member.
Absent Member.
1505 views

Net Express: how to connect to a db without getting prompts / selecting a DSN

Jump to solution

[Migrated content. Thread originally posted on 07 May 2012]

I'm only able to connect to my Oracle database via:

-Going control panel -> administrative tools -> ODBC data source manager; creating a DSN for Oracle XE

-Putting he following in the program: exec sql CONNECT WITH PROMPT end-exec

-Once the program's running, a prompt appears; I select the aforementioned DSN.

-Then a prompt corresponding to that DSN appears; I type service name, user name, password.


Are there simpler ways for this? Something akin to a connection string? My main hope is to be able to skip the prompt for DSN and its creation, and maybe the prompt asking for password. I.e. ideally as soon as the program's running it connects right away with no need for user input.

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert
You can use Format 6 of the Connect Statement to specify an input_connection string


Format 6
>>----EXEC SQL---CONNECT USING input_connection---------->

>-----.-------------.---.---------------------.---------->
       +--AS db_name-+   +--WITH-.----.-PROMPT-+
                                 +-NO-+

>-----.------------------------------.------END-EXEC----><
       +--RETURNING output_connection-+



Example in Net Express documentation for Excel:


01  connectString               PIC X(72) value
                   'DRIVER={Microsoft Excel Driver (*.xls)};'
                   &'DBQ=c:\demo\demo.xls;'
                   &'DRIVERID=22'
                   .

procedure division.

     EXEC SQL
         CONNECT USING :connectString
     END-EXEC


The example above connects to an Excel spreadsheet without setting up a data source


Several examples for Oracle connect strings can be found here.

Including the following for Oracle XE:

Driver=(Oracle in XEClient);dbq=111.21.31.99:1521/XE;Uid=myUsername;Pwd=myPassword;

View solution in original post

0 Likes
2 Replies
Highlighted
Absent Member.
Absent Member.
Well, I found something that solves most of it:

EXEC SQL
    CONNECT TO 'nameOfTheDsn' USER 'username.password'
END-EXEC


Of course, the DSN still needs to have been created manually beforehand; no ways around that?
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert
You can use Format 6 of the Connect Statement to specify an input_connection string


Format 6
>>----EXEC SQL---CONNECT USING input_connection---------->

>-----.-------------.---.---------------------.---------->
       +--AS db_name-+   +--WITH-.----.-PROMPT-+
                                 +-NO-+

>-----.------------------------------.------END-EXEC----><
       +--RETURNING output_connection-+



Example in Net Express documentation for Excel:


01  connectString               PIC X(72) value
                   'DRIVER={Microsoft Excel Driver (*.xls)};'
                   &'DBQ=c:\demo\demo.xls;'
                   &'DRIVERID=22'
                   .

procedure division.

     EXEC SQL
         CONNECT USING :connectString
     END-EXEC


The example above connects to an Excel spreadsheet without setting up a data source


Several examples for Oracle connect strings can be found here.

Including the following for Oracle XE:

Driver=(Oracle in XEClient);dbq=111.21.31.99:1521/XE;Uid=myUsername;Pwd=myPassword;

View solution in original post

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.