I am creating an application that will move specific data from one Oracle database and moving it to a MySQL database. I created this class to help keep myself organized and this class holds all of the operations/communication that will happen with this database. I have learned C# on my own with no formal training I was just wanting some pointers that could help me make my code to be acceptable if I was working as a developer for a company.
class Oracle
{
//private properties
private OracleConnection oConnection;
private XmlDocument oXML;
private string oUID;
private string oPassword;
private string oSecurity;
private string oDb;
private string oConString;
private OracleDataAdapter oCommand;
private string oScript;
private DataSet oData;
private DataTable oTable;
public Oracle()
{
oConnection = new OracleConnection();
oXML = new XmlDocument();
try
{
oXML.Load(@"C:\Users\V64016\documents\visual studio 2013\Projects\Test_DB_Connection\Test_DB_Connection\Resources\Test.xml");
oSecurity = oXML.SelectSingleNode("/Connections/Oracle/Security").InnerText;
oDb = oXML.SelectSingleNode("/Connections/Oracle/Database").InnerText;
oUID = oXML.SelectSingleNode("/Connections/Oracle/UId").InnerText;
oPassword = Encrypt.DecryptString(oXML.SelectSingleNode("/Connections/Oracle/Pwd").InnerText,oUID);
oConString = "Data Source=" + oDb + ";User Id=" + oUID + ";Password=" + oPassword + ";";
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
Debug.Print(ex.ToString());
}
}
//method that handles opening the connection to the database
public void Open()
{
try
{
oConnection.ConnectionString = oConString;
oConnection.Open();
Console.WriteLine("Oracle DB Connection Established");
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
Debug.Print(ex.ToString());
}
}
//method that handles closing the connection to the database
public void Close()
{
try
{
oConnection.Close();
Console.WriteLine("Oracle DB Connection Closed");
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
Debug.Print(ex.ToString());
}
}
//method that handles pulling the data from a table
public DataTable Pull()
{
oCommand = new OracleDataAdapter();
oData = new DataSet();
oTable = new DataTable();
try
{
oScript = System.IO.File.ReadAllText(@"C:\Users\V64016\documents\visual studio 2013\Projects\Test_DB_Connection\Test_DB_Connection\Resources\CASE_SELECT.sql");
oCommand.SelectCommand = new OracleCommand(oScript, oConnection);
oCommand.Fill(oData, "uds9");
oTable = oData.Tables["uds9"];
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
Debug.Print(ex.ToString());
}
return oTable;
}
}