VB.net connecting Oracle and PHP to Oracle

Source: Internet
Author: User

1. VB.netCodeAs follows:

Dim ss as string
'Specify the connection string => 0 K
Ss = "(description = (address_list = (address = (Protocol = TCP) (host = 192.168.77.128) (Port = 1521) (CONNECT_DATA = (SERVICE_NAME = orcl )))"
'Specify the name of the service that has been created through the Oracle client ==> OK
Ss = "ora_128"
'Data source created using ODBC
Ss = "orcl"
Dim myconnection as data. oledb. oledbconnection
Dim myoracledataadapter as data. oledb. oledbdataadapter
Myconnection = new data. oledb. oledbconnection ("provider = oraoledb. Oracle; Data Source =" + SS + "; user id = Scott; Password = tiger ")
Myoracledataadapter = new data. oledb. oledbdataadapter ("select 'A' from dual", myconnection)
Dim mydataset as data. dataset = new data. dataset ()
Myoracledataadapter. Fill (mydataset, "dual ")
Response. Write (txtname. Text + mydataset. Tables ("dual"). Rows (0) (0 ))

(Note: my personal feelings for these three methods are as good as possible. It seems that Java is directly connected using the protocol. Both the second and third types require the Oracle client to be installed. Configure the service name. Note that When configuring the ODBC data source, pay attention to the third method. Select system DSN and add ..., select the Oracle driver, for example, 'oracle in stronglient10g'. This is the driver for installing the Oracle client. Do not select Micrsoft ODBC for Oracle. Add the required information, that is, OK)

2. php connection to Oracle

$ SQL = "select 'A' from dual ";
// Use the Oracle connection string to directly establish a connection with the database ==> OK
$ Ss = "(description = (address_list = (address = (Protocol = TCP) (host = 192.168.77.128) (Port = 1521) (CONNECT_DATA = (SERVICE_NAME = orcl ))) ";
// Use the 'service name' created by the Oracle Net manager tool to connect to the instance => 0 K
$ Ss = "ora_128 ";
$ Handler = ocilogon ("Scott", "Tiger", $ SS, "al32utf8 ");
$ Stmt = ociparse ($ handler, $ SQL );
Ociexecute ($ stmt, oci_default );
// Traverse the result
If (ocifetchinto ($ stmt, $ row ))
{
Echo $ row [0];
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.