繁体中文
设为首页
加入收藏
当前位置:.Net技术首页 >> Asp.Net开发 >> Connect To Oracle DataBase

Connect To Oracle DataBase

2007-07-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介:Connect to Oracle Database Submitted ByUser LevelDate of SubmissionRavi ShankarBeginner05/03/2001 Description of the Article A Simple program to show connecting to an oracle database. Source Code:...
关键字:DataBase Connect Oracle To

Connect to Oracle Database

Submitted ByUser LevelDate of SubmissionRavi ShankarBeginner05/03/2001

Description of the Article

A Simple program to show connecting to an oracle database.

Source Code:

/***********************************************************************/

//Program Name : ADO Connection to Oracle

//Description : A Sample program to connect to the oracle database

//Created On : 01 May 2001

//Created By : Ravi Shankar Venkatarajalu

/***********************************************************************/

using System;

using System.Data;

using System.Data.ADO;

class OracleTest

{

static void Main()

{

//UID - User Id

//PWD - Password

//Server - Your Service name

//Using Microsoft ODBC for Oracle DSN-Less

//const string strConn = "Provider=MSDASQL;DRIVER={Microsoft

ODBC for ORACLE};UID=scott;PWD=tiger;Server=fnqa";

//Using Microsoft OLEDB Provider for Oracle

const string strConn = "Provider=MSDAORA.1;Data

Source=oracle_db;User ID=scott;Password=tiger";

//Using DSN Connection

//const string strConn =

"DSN=oracle_dsn;UID=scott;PWD=tiger" ;

const string strSQL = "Select * From EMP";

try

{

DataSet ds = new DataSet("EmployeesSet");

ADODataSetCommand myCommand = new

ADODataSetCommand(strSQL,strConn);

myCommand.FillDataSet(ds,"Buyer");

Console.WriteLine(ds.XML);

}

catch(ADOException e)

{

Console.WriteLine("Exception Occured :

{0}",e.Errors[0].Message);

}

}

}

责任编辑:admin
相关文章