首页 > 开发 > 综合 > 正文

连接到oracle数据库(一)

2024-07-21 02:23:45
字体:
来源:转载
供稿:网友
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);
}


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