data source=torcl;user id=myusername;password=mypassword;
data source=(description=(address_list=(address=(protocol=tcp)(host=myhost)(port=myport)))(connect_data=(server=dedicated)(service_name=myoraclesid)));user id=myusername;password=mypassword;
oracle客户端
tnsnames.ora
listlp=new list();
string sql = "select * from man";
try
{
orc.open();
oraclecommand cmd = new oraclecommand(sql, orc);
oracledatareader odr = cmd.executereader();
while(odr.read())
{
per p = new per();
p.id=(int)odr["id"];
p.name=(string)odr["name"];
p.sex=(string)odr["sex"];
p.age=(int)odr["age"];
p.address=(string)odr["address"];
lp.add(p);
odr.close();
}
return lp;
}
catch (exception e)
{
console.writeline("出错啦!原因是:"+e.message);
return null;
}
finally
{
orc.close();
}