I've been working on a C# Web Application for a while now, with the purpose of pulling values from a table and displaying them in a list box. However, once I run this program, it throws an exception at Line 37:
System.TypeInittalizationException: 'The type initializer for
'Oracle.DataAccess.Client.OracleConnection' threw an exception.'
Inner Exception
OracleException: The provider is not compatible with the version of
Oracle Client
I've been searching for possible solutions across the internet, but they are all pretty outdated and I haven't been able to catch onto any fixes (I am relatively new and inexperienced with Oracle).
Here is the code. Any help would be appreciated.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Oracle.ManagedDataAccess;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
namespace Employee_Web_3
{
public partial class FirstWebPage : System.Web.UI.Page
{
int MAX;
List<string> save_vector = new List<string>();
List<string> line_vector = new List<string>();
List<string> singled_vector = new List<string>();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e) //Pull Values
{
MAX = int.Parse(Value_Count.Text);
if (MAX <= 0)
{
Failure_Notice.Visible = true;
Failure_Notice.Text = "Enter in a number greater than 0!";
}
else
{
string constr = "User Id=USER; Password=PASSWORD; Data Source=ORACLE DATABASE; enlist=false; pooling=false";
OracleConnection conn = new OracleConnection(constr); //This is where the exception is being thrown
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
string line = MAX.ToString();
cmd.CommandText = "select (employee_fname || ', ' || employee_lname || ' ' || employee_id) from Employee where employee_id <= " + line;
cmd.CommandType = CommandType.Text;
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
E_List.Items.Add(dr.GetString(0));
}
for (int i = 0; i < E_List.Items.Count; i++)
{
save_vector.Add(E_List.Items[i].ToString());
line_vector.Add(E_List.Items[i].ToString());
}
conn.Dispose();
E_List.Visible = true;
Pull_Values.Visible = false;
Value_Count.Visible = false;
Failure_Notice.Visible = false;
Prompt_.Visible = false;
}
}
}
}
If anyone is able to give a solution, I would be very thankful