// Add two references first
Using System. Data. OracleClient;
Using System. Data;
String ConnectionString = "Data Source = sky; user = system; password = manager;"; // write the connection string
OracleConnection conn = new OracleConnection (ConnectionString); // create a new connection
Try
{
Conn. Open ();
OracleCommand cmd = conn. CreateCommand ();
// Write SQL statements here
Cmd. CommandText = "select * from MyTable ";
// Create an OracleDateReader object
OracleDataReader odr = cmd. ExecuteReader ();
// Read data. If odr. Read () returns false, it indicates the end of the record set.
While (odr. Read ())
{
// Output field 1, which is a field index. How to use the field name remains to be studied
Response. Write (odr. GetOracleString (1). ToString ());
}
Odr. Close ();
}
Catch (Exception ee)
{
Response. Write (ee. Message); // if an error occurs, the error Message is output.
}
Finally
{
Conn. Close (); // Close the connection
}