1。vb.net代码如下

Dim ss As String
' 指定连接字符串==〉0k
ss = "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.77.128)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl)))"
' 指定已经通过oracle client创建的 服务命名 ==> Ok
ss = "ORA_128"
' 使用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 'aa' 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))

(注释:我个人对这三种方法的感觉是,第一种好。好像java就是使用协议直接连接的。第二种和第三种都要安装oracle的客户端。配置 服务命名。注意第三种方法中,配置odbc数据源的时候,要注意。选择系统DSN,添加。。。,选择oracle驱动,例如‘oracle in oraClient10g’这是安装oracle客户端的驱动,不要选择 Micrsoft ODBC for oracle,添些必要的信息,即ok)

2.php连接oracle

$sql="select 'aa' from dual";
// 使用oracle连接字符串直接和数据库建立连接 ==〉ok
$ss = "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.77.128)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl)))";
// 使用 ORACLE NET MANAGER 工具创建的'服务命名',来连接 ==〉0k
$ss = "ORA_128";
$handler=OCILogon("scott","tiger",$ss,"AL32UTF8");
$stmt   =OCIParse($handler, $sql);
ociexecute($stmt, OCI_DEFAULT);
// 遍历结果
if (OCIFetchInto($stmt,$row))
{
echo $row[0];
}