首页 > 开发 > 综合 > 正文

Connect To Oracle DataBase

2024-07-21 02:23:44
字体:
来源:转载
供稿:网友

connect to oracle databasesubmitted 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);
}


}
}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表