asp教程.net c连接oracle数据库教程并显示数据
本款是是由asp.net教程 与oracle数据库连接,并且显示数据中的所有数据哦。
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();
}