C# - Oracle数据库连接方法

发表于:2007-06-30来源:作者:点击数: 标签:
using System; using System.Data; using System.Data. Oracle Client; class Sample { public static void Main() { string myConnString = user id=zk;data source=zkqx;password=*****; OracleConnection myConnection = new OracleConnection(myConnStrin
using System;
using System.Data;
using System.Data.OracleClient;

class Sample
{
public static void Main()
{
string myConnString = "user id=zk;data source=zkqx;password=*****";
OracleConnection myConnection = new OracleConnection(myConnString);

OracleCommand catCMD = myConnection.CreateCommand();
catCMD.CommandText = " SELECT CZYDM,CZYMC,CZYMM,CZYQX FROM ZC_CZY ";

myConnection.Open();

OracleDataReader myReader = catCMD.ExecuteReader();

while (myReader.Read())
{
Console.WriteLine("\t{0}\t{1}\t{2}\t{3}", myReader.GetString(0),myReader.GetString(1),myReader.GetString(2),myReader.GetString(3));
}

myReader.Close();

myConnection.Close();
}
}


原文转自:http://www.ltesting.net