The provider is not compatible with the version of oracle (ASP.NET Core MVC) - oracle

I'm really frustrated and i do not know what to do.
I'm trying to connect to an Oracle 11g database but every time I try to connect Visual Studio 2019 throws an error message. I already tried a lot of different things but nothing really helped me.
I have already made sure the app set to run in 32 bit mode in the IIS console. I still can't figure out why is not working.
By the way, here is my code:
readonly string connectionString = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xxxxxxxxx)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=PROD)));User Id=xxx;Password=xxxx;"
public IEnumerable<Person>GetPersonList
{
var listPerson = new List<Person>();
using (OracleConnection con = new OracleConnection(connectionString))
{
OracleCommand cmd = new OracleCommand("select * from myview", con);
cmd.Connection = con;
cmd.InitialLOBFetchSize = 1000;
cmd.CommandType = CommandType.Text;
con.Open();
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
var list = new Person();
list.CODE = Convert.ToInt32(dr["CODE"].ToString());
list.NAME = dr["NAME"].ToString();
list.LASTNAME = dr["LASTNAME"].ToString();
listPerson.Add(list);
}
con.Close();
}
return listPerson;
}
What should I do?

My problem was solved: needed to install instant client for Oracle 11g and everything worked just fine

Related

How To Use ODAC With Visual Studio 2015 Call Oracle DB (Stored-Function)

There is a strange problem that has been found in Oracle DB with Visual Studio by my project. First I open my Toad to check Oracle function like as below picture:
When I have put 3 parameter's value into SF_GET_COMP_SVAL, it is working ,and then when I have tried it in my project as following, it also works very well.
using (OracleConnection con = new OracleConnection(ConfigurationManager.ConnectionStrings["OracleDbContext"].ToString()))
{
using (OracleCommand cmd = new OracleCommand())
{
cmd.CommandText = "select PG_AIS.SF_GET_COMP_SVAL('3','2','1') from dual";
try
{
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
}
catch
{
}
}
}
However it can't be working when I use Paramters mode like as following code
cmd.CommandText="select PG_AIS.SF_GET_COMP_SVAL(:a1,:a2,:a3) from dual"; cmd.Parameters.Add("a2", "1");
cmd.Parameters.Add("a3", "2");
cmd.Parameters.Add("a1", "3");
why????
I wasted half day and have found the ODAC problem in my case, why can't insert into data with paramters in Visual Studio platform , because of parameters name , if fact in my MySql and MSSql there don't need to follow the sequence with parameter , but unfortunately in the Oracle it can't change ordering ,the parameter's depends on index sequence so that you can change any parameter's name
cmd.CommandText="select PG_AIS.SF_GET_COMP_SVAL(:a1,:a2,:a3) from dual";
cmd.Parameters.Add("a1", "3");
cmd.Parameters.Add("a2", "2");
cmd.Parameters.Add("a3", "1");
or
cmd.CommandText="select PG_AIS.SF_GET_COMP_SVAL(:a1,:a2,:a3) from dual";
cmd.Parameters.Add("xx", "3");
cmd.Parameters.Add("a2", "2");
cmd.Parameters.Add("a3", "1");
parameter a1 or xx is the same (depends on index sequence not parameter name)
both codes can get the same result.
PS: Hopefully it will be modify soon by Oracle Provider.
I have found another method to deal with this problem , please try it
OracleCommand command = new OracleCommand(query, connection)
{ CommandType = CommandType.Text, BindByName = true };
PS:http://www.codeproject.com/Articles/208176/Gotcha-sharp-Using-Named-Parameters-with-Oracl <-- it could be a great way to deal with

how to connect MS Access (x86) DB using Microsoft Jscript running in x64 bit Environment

I am trying to connect an MS Access (x86) database (*.mdb) from a third party application which is x64 bit and supports Microsoft JScript ...
My Code Looks like below:
function testaccess(sender : System.Object, cmdArgs : Ico.Gwx.CommandExecutionEventArgs)
{
try
{
strConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\EC_SCADA\\Configurations\\ModbusEthernetConfig\\EC_ModbusOPC_Config.mdb;Persist Security Info=False";
var cnn = System.Data.OleDb.OleDbConnection;
var cmd = System.Data.OleDb.OleDbCommand;
var qr1 : String = "Select IPAddress from Devices where Name = 'Machine1'";
var da : System.Data.OleDb.OleDbDataAdapter;
var dt : System.Data.DataTable;
//MessageBox.Show("Variables defined");
cnn = new System.Data.OleDb.OleDbConnection(strConnectionString);
//MessageBox.Show("cnn defined");
cmd = new System.Data.OleDb.OleDbCommand(qr1, cnn);
//MessageBox.Show("cmd defined");
da = new System.Data.OleDb.OleDbDataAdapter(cmd);
cnn.Open();
MessageBox.Show("Connection Opened");
da.Fill(dt);
MessageBox.Show("Code End");
}
catch (e)
{ MessageBox.Show("OOPS!!! something went wrong, Kindly try again!!!!");
}
}
First of all the Code editor itself throws error at line "da = new..." as "More than one constructor matches this argument list"
Can anyone help on this??
I found couple of issues here.
[1] missed to define dataTable like
"dt = new System.Data.DataTable"
[2] I downloaded and installed "Microsoft Access Database Engine 2010 Redistributable - 64 bit" from Below link, installed on my computer and the code just works fine.
[https://www.microsoft.com/en-gb/download/details.aspx?id=13255]

Push data from a web from into CRM 2015 online

I am trying to create a web from (web application) in Visual Studio 2012 to push data into CRM 2015 online. It keep saying Metadata Contains A Reference That Cannot Be Resolved, when the program tried to call OrgService.
Before that, I create a windows form to do so, it works fine. It can connect to CRM 2015 online and create a new entity record successfully. But when I move the code to Web Application. I does not work.
Code:
private void button1_Click(object sender, EventArgs e)
{
ClientCredentials cre = new ClientCredentials();
cre.UserName.UserName = "MyEmailAddress";
cre.UserName.Password = "Password";
Uri serviceUri = new Uri("https://QA.crm.dynamics.com/XRMServices/2011/Organization.svc");
OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, null, cre, null);//Error occurs here!!!!!!
proxy.EnableProxyTypes();
IOrganizationService service = (IOrganizationService)proxy;
Entity contact = new Entity("contact");
contact["firstname"] = Convert.ToString(firstname.Text);
contact["lastname"] = Convert.ToString(lastname.Text);
contact["emailaddress1"] = Convert.ToString(email.Text);
contact["mobilephone"] = Convert.ToString(phone.Text);
proxy.Create(contact);
}
Error occurs at:
OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, null, cre, null);
Is there anyone know what is going on here? I appreciate your help.
Thanks.
Try to use following code for initialization of service proxy:
IServiceManagement<IOrganizationService> orgServiceManagement =
ServiceConfigurationFactory.CreateManagement<IOrganizationService>(new Uri("https://democrm.api.crm5.dynamics.com/XRMServices/2011/Organization.svc"));
AuthenticationCredentials authCredentials = new AuthenticationCredentials();
authCredentials.ClientCredentials.UserName.UserName = _userName;
authCredentials.ClientCredentials.UserName.Password = _password;
AuthenticationCredentials tokenCredentials = orgServiceManagement.Authenticate(authCredentials);
IOrganizationService organizationProxy = new OrganizationServiceProxy(orgServiceManagement, tokenCredentials.SecurityTokenResponse);

C# - Oracle Connectivity

My connection is failing with the following message: "The procedure entry point ons_subscriber_cancelcallback could not be located in the dynamic link library oraons.dll".
Can anyone please help ?
The code is pretty straight forward:
string oradb = "";
oradb = "Data Source=MYORADB;Password=MYPASS123;User ID=MYUSERID;";
OracleConnection conn = new OracleConnection(oradb);
conn.Open();
I have already connected TOAD with these credentials.
For me, the solution was to go to the Oracle website where I downloaded and installed the latest version of the Oracle Data Access Components (ODAC).
You'll want to be careful to install the correct version for your programming environment. In my case, it was version 12c (64-bit).
From there, I redirected the Oracle.DataAccess.dll reference to the version that I'd just installed.
You don't seem to have a database IP or port number there. Once you have those available, try using the Oracle EZCONNECT format:
//Check that MYORADB is your actual SID number
string oradb = getConnectionString("10.1.2.3", 1521, "MYORADB", "MYUSERID", "MYPASS123");
OracleConnection conn = new OracleConnection(oradb);
conn.Open();
private static string getConnectionString(string databaseIP, int databasePort, string databaseSID, string databaseUN, string databasePW)
{
return string.Format(
"Data Source=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = {0})(PORT = {1}))(CONNECT_DATA =(SID = {2})));" +
"Persist Security Info=True;User ID={3};Password={4}",
databaseIP, databasePort, databaseSID, databaseUN, databasePW
);
}

I am not able to connect to Oracle XE database in another system?

I have used this code to connect to XE database:
OracleConnection con = new OracleConnection();
con.ConnectionString = "data source=XE;user id=hr;password=sdmo1365";
con.Open();
OracleCommand com = new OracleCommand();
com.CommandText = "select * from regions;";
com.Connection = con;
DataTable dt = new DataTable();
dt.Load(com.ExecuteReader());
con.Close();
grd.DataSource = dt;
grd.DataBind();
it is working in one pc while not working in another and giving this error:
oracleexception was unhandled by user code
the only difference in tnsnames.ora of those pc is in the one that is not working the host is longer(becuase the user is under domain:)
(HOST = MOSININI-9.novini.mms.sti)
is this making the problem?
thanks
I simply reinstalled it and everything get solved!(I waste 2 hours)

Resources