日期:2014-05-18 浏览次数:21130 次
OracleConnection myConnection = new OracleConnection(@"Data Source=orcl;User ID=shibei;Password=nsic;Unicode=True");//创建连接对象 myConnection.Open(); //建立连接 OracleCommand myCommand = myConnection.CreateCommand(); //创建命令对象 myCommand.CommandText = "select * from N_AIT"; //提供SQL命令 OracleDataReader myReader = myCommand.ExecuteReader(); //执行命令返回结果指派给DataReader对象 while (myReader.Read()) //从读取器中获取结果 { Console.WriteLine("{0}\t{1}", myReader["ID"], myReader["NAME"]); } myReader.Close();//关闭DataReader myConnection.Close();//关闭数据库连接
------解决方案--------------------
Console.WriteLine("{0}\t{1}", myReader["ID"], myReader["NAME"]);
{0}对应myReader["ID"]
{1}myReader["NAME"]
同类的有string.format(“select * from table where a={0},b={1}”a,b);