OracleConnection对象
l//设置连接字符串
string connstring="Data Source=eims;user=zbmis;password=zbmis;";
//实例化OracleConnection对象
OracleConnection conn=new OracleConnection(connstring); l打开连接 conn.Open(); l关闭连接conn.Close();
示例Oracle表
l建立一个名为OracleTypesTable的表
"create table OracleTypesTable (MyVarchar2 varchar2(3000),MyNumber number(28,4)
Primary key ,MyDate date,MyRaw RAW(255))";
l插入一行数据
"insert into OracleTypesTable values ('test',4,to_date('2000-01-11
12:54:01','yyyy-mm-dd hh24:mi:ss'),'0001020304')";
OracleCommand对象
l OracleCommand cmd=conn.CreateCommand(); l 或者: l OracleCommand cmd=new OracleCommand(); l cmd.Connection=conn; lcmd.CommandText="select * from zbmis.OracleTypesTable";
OracleDataReader
l OracleDataReader oracledatareader1=cmd.ExecuteReader();
//读取数据
while (oracledatareader1.Read()) l {
…. l }
读取字符数据
l//读取并显示第一行第一列的数据
OracleString oraclestring1=oracledatareader1.GetOracleString(0);
Response.Write("OracleString " +oraclestring1.ToString());