写道
OracleConnection thisConnection = new OracleConnection();
thisConnection.ConnectionString = @"Data Source=gxmis;Persist Security Info=True;User ID=system;Password=admin";
try
{
thisConnection.Open();
OracleDataAdapter thisAdapter = new OracleDataAdapter("select * from student", thisConnection);
DataSet thisDataSet = new DataSet();
thisAdapter.Fill(thisDataSet,"student");
foreach (DataRow theRow in thisDataSet.Tables["student"].Rows)
{
Console.WriteLine(theRow["student_id"] + "\t" +theRow["student_name"] );
}
thisConnection.Close();
}
catch (OracleException oe)
{
Console.WriteLine("数据库连接失败");
Console.WriteLine(oe.Message);
}
thisConnection.ConnectionString = @"Data Source=gxmis;Persist Security Info=True;User ID=system;Password=admin";
try
{
thisConnection.Open();
OracleDataAdapter thisAdapter = new OracleDataAdapter("select * from student", thisConnection);
DataSet thisDataSet = new DataSet();
thisAdapter.Fill(thisDataSet,"student");
foreach (DataRow theRow in thisDataSet.Tables["student"].Rows)
{
Console.WriteLine(theRow["student_id"] + "\t" +theRow["student_name"] );
}
thisConnection.Close();
}
catch (OracleException oe)
{
Console.WriteLine("数据库连接失败");
Console.WriteLine(oe.Message);
}