I'm looking for best practices for establishing connections between Oracle 8 and Visual Studio 2005 applications. The target would be a Windows Forms application written in C# that hits the database once a second to monitor tables looking for their last inserted record. I'm considering using "Application settings" to store the connection string there, but I'd love to hear from you guys. Thanks in advance!
This is a very rudimentary draft:
using System.Data;
using System.Data.OracleClient;
try
{
StringBuilder str = new StringBuilder();
string ora = Properties.Settings.Default.OracleConnectionString;
OracleConnection con = new OracleConnection(ora);
OracleCommand cmd = new OracleCommand();
cmd.Connection = con;
cmd.CommandText = "SELECT timestamp FROM jde_out WHERE rownum = 1";
cmd.CommandType = CommandType.Text;
con.Open();
OracleDataReader rdr = cmd.ExecuteReader();
rdr.Read();
str.AppendLine(cmd.ExecuteScalar().ToString());
this.lblJDEtime.Text = str.ToString();
rdr.Close();
con.Close();
}
catch (OracleException err)
{
MessageBox.Show("Exception caught:\n\n" + err.ToString());
}
I've just updated the code needed to perform the connection. Changed the Exception type to the more specific OracleException. Added the connection string via Properties.Settings.