Delphi5 Enterprise Edition uses BDE to access the Oracle method

zhaozj2021-02-08  259

System environment:

1, operating system: Windows 2000 Server

2, Database: Oracle 8i R2 (8.1.6) for NT Enterprise Edition

3. Development Tools: Delphi 5 Enterprise Edition

connection method:

First, install Oracle 8i R2 (8.1.6) for NT Enterprise Edition

Use a typical installation, the installation directory is d: / oracle;

Second, install Delphi 5 Enterprise Edition

Put Delphi 5 CD into the optical drive, use a typical installation,

The installation directory is c: / program files / borland / delphi5;

Third, generate Oracle experiment records

Enter SQL * PLUS to log in with System / Manager user

SQL> CONN SYSTEM / MANAGER

Create new users: such as user1 / pass1, give Connect, Resource Permissions.

SQL> Grant Connect, Resource To User1 Identified by Pass1;

SQL> Conn User1 / Pass1

SQL> Create Table Test (A Number, B CHAR (19));

SQL> INSERT INTO TEST VALUES (1, To_Char (Sysdate, 'YYYY-MM-DD HH24: MI: SS'));

SQL> INSERT INTO TEST VALUES (2, To_Char (Sysdate, 'YYYY-MM-DD HH24: MI: SS'));

SQL> INSERT INTO TEST VALUES (3, TO_CHAR (SYSDATE, 'YYYY-MM-DD HH24: MI: SS'));

SQL> INSERT INTO TEST VALUES (4, To_CHAR (Sysdate, 'YYYY-MM-DD HH24: MI: SS'));

SQL> INSERT INTO TEST VALUES (5, TO_CHAR (Sysdate, 'YYYY-MM-DD HH24: MI: SS'));

SQL> commit;

SQL> SELECT *.

A b

---------- -------------------

1 2000-11-28 20:27:33

2 2000-11-28 20:27:36

3 2000-11-28 20:27:38

4 2000-11-28 20:27:40

5 2000-11-28 20:27:52

D: /oracle/ora81/neetwork/admin/tnsnames is as follows:

Test =

(Description =

(Address_list =

(Address = (protocol = tcp) (host = HLSHANG) (port = 1521))

)

(Connect_data =

(Service_name = ORADB)

)

)

to sum up:

Oracle service_names: ORADB

Oracle User Name: User1

Account Name Password: Pass1

Test Name: Test

TNSNAMES: TEST

Fourth, configure BDE

Start -> Program -> BORLAND Delphi 5-> BDE Administrator

1. Configure Drivers to modify the following places, as shown below: DLL32: SQLORA8.DLL

Vendor init: oci.dll

Langdriver: Oracle SQL WE850

SQLPASSTHRU MODE: Shared Noautocommit

After the modification, right-click, Apply (Ctrl A), submit a modification

2, configure Database Aliases, create a new alias, named Oracle, as shown below:

3. Modify the following places, as shown below:

Server Name: Test

After the modification, right-click, Apply (Ctrl A), submit a modification, exit BDE Administrator

Re-open BDE Administrator, use the left mouse button to double-click the name Oracle, perform the connection test

Enter your username, password, press "OK" connection, can not write user1 / pass1 directly on user name, to be separated

If a picture appears, the connection is successful

5. Start Delphi 5 Enterprise Edition, write the Delphi program connected to Oracle

Start -> Program -> Borland Delphi 5-> Delphi 5

File-> new ...-> Application, as shown below:

Toolbox panel above the Delphi development window:

Open the Data Access control group, double-click the control table with the mouse, then double-click the DataSource control (two of the picture draws the red box above),

Place them on the form form1, the default name is Table1 and DataSource1:

Open the Data Controls control group, double-click the DBGRID control with the mouse (draw a red box above),

Place it on the form FORM1, the default name is dbgrid1, as shown below:

Modify the properties of the control table1, datasource1, dbgrid1, as shown below:

Table1 Active Properties: True

Table1's DatabaseName Property: Oracle (ie the selected BDE name)

Table1's Tablename Properties: Test (here you need to connect to Oracle)

DataSource DataSet Properties: Table1

Datasource attribute of DBGRID: Datasource1

Press F9, run this procedure, pop up the login screen, as shown below:

Enter your username, password, press "OK", the result is as follows:

转载请注明原文地址:https://www.9cbs.com/read-1561.html

New Post(0)