I installed 64-bit ODAC 12c Release 4 (12.1.0.2.4) for Windows x6464-bit on my machine. and used this to connect to a remote oracle db. this worked well when I deployed to a normal IIS. But when is published to azure as an Azure cloud service (my project is a WCF service). I get the following error
System.DllNotFoundException: Unable to load DLL 'OraOps12.dll'
Now I have no idea why this is happening. This is the code I'm using to connect to db
OracleConnection con = new OracleConnection();
con.ConnectionString = "User Id=Usr;Password=*****;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=xxx.xxx.xxx.xxx)(PORT=xxxx)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
con.Open();
OracleCommand comm = new OracleCommand();
string comandtext = "Select * from COR_EMPL_MASTER where EMPL_CODE='" + u.EMPL_EMPL_Code + "'";
DataSet ds = new DataSet();
OracleDataAdapter da = new OracleDataAdapter(comandtext, con);
da.Fill(ds);
This is because there is no OraOps12.dll file on azure.
You can throw OraOps12.dll into /Bin folder in your project and add Reference for it by virsual studio. After that you can publish your project to Azure cloud service.
finally fixed it
Hey use this link to http://alderprogs.blogspot.com/2009/04/deploying-odpnet-with-oracle-instant.html. Firstly use the Xcopy version of the drivers downloaded from here http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html add reference to Oracle.dataaccess.dll from this after which right click on it and select properties and in the properties set "local copy=true"
then what you have to do is right-click on the project select "Add Existing Item". Add all the required dlls like oci.dll,OraOps12.dll etc. Now in the properties of these of these dlls set "Copy to output directory = Copy if Newer" and publish to azure it will work.
Related
I have a C# exe, called 'start.exe' that is when run will check a SQL database and copy a file to a folder if certain criteria are met.
This works on most computers.
But on some computers when I try to run it I get the following error message.
System.invalidOperationException: The 'Microsoft.ACE.OLEDB.12.0' is not registered on the local machine
To fix this I created a setup project that should add the missing .dll.
I created the set up project, went to the applications folder, added the primary output of the project.
I then ran a batch build on all the files and copied the msi and setup .exe files to a problem computer and ran it.
It adds System.Net.Http.dll and 'start.exe' to the computer.
When I run the exe, it still gives me the same error.
I believe the message box comes from these lines of code.
try
{
using (var conn = new OleDbConnection(#"Provider =Microsoft.ACE.OLEDB.12.0;Data Source=" + CurFeSource + ";"))
{
conn.Open();
using (var cmdBE = new OleDbCommand("SELECT value FROM Tab1", conn))
{
OleDbDataReader rdrBE = cmdBE.ExecuteReader();
rdrBE.Read();
be_version = (rdrBE.GetString(0));
rdrBE.Close();
}
using (var cmdFE = new OleDbCommand("SELECT Col FROM Links", conn))
{
OleDbDataReader rdrFE = cmdFE.ExecuteReader();
rdrFE.Read();
fe_version = (rdrFE.GetString(0));
rdrFE.Close();
}
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
return false;
}
Edit:
As SQLGeorge said, I need to install Microsoft.ACE.OLEDB.12.0.
But how do I add it to a setup project.
The Microsoft.ACE.OLEDB.12.0 must be downloaded from Microsoft:
https://www.microsoft.com/en-US/download/details.aspx?id=13255
Excerpt From Microsoft:
This download will install a set of components that facilitate the transfer of data between existing Microsoft Office files such as Microsoft Office Access 2010 (*.mdb and .accdb) files and Microsoft Office Excel 2010 (.xls, *.xlsx, and *.xlsb) files to other data sources such as Microsoft SQL Server. Connectivity to existing text files is also supported. ODBC and OLEDB drivers are installed for application developers to use in developing their applications with connectivity to Office file formats.
As noted by Microsoft:
As a general replacement for Jet (If you need a general replacement for Jet you should use SQL Server Express Edition).
The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
I know the common fix for this which is to install:
Microsoft Access Database Engine 2010 Redistributable
Or
2007 Office System Driver: Data Connectivity Components
Both are installed on my local PC. This is the code which I have
OleDbConnection conn = new OleDbConnection();
string fileName = "test.xlsx";
try
{
string connectString = String.Format(
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 12.0 Xml;HDR={1};'",
fileName, "YES");
conn.ConnectionString = connectString;
conn.Open(); //exception is thrown here !!!
OleDbCommand comm = new OleDbCommand();
comm.CommandText =
string.Format("CREATE TABLE [{0}] ", "Test");
comm.Connection = conn;
comm.ExecuteNonQuery();
OleDbDataAdapter ad = new OleDbDataAdapter(
string.Format("SELECT * FROM [{0}]", "Test"), conn);
OleDbCommandBuilder builder = new OleDbCommandBuilder(ad);
}
catch(Exception ex)
{
throw ex;
}
finally
{
conn.Close();
}
I try this code in other projects on my local machine and everything is working. I have project which creates excel exports and I don't have this problem.
The problem is in the project I don't understand how to fix it. Also on the current project I create one new .aspx page and in Page_Load put only this code, same exception.
Additional information: this project was written on vs 2008, convert to 2010 and after that used in vs 2012. Everything was working in the project till now.
Also same thing for JET connection string !
EDIT
After the answer of Joe I see that this project is run on 64bitProcess:
bool test = Environment.Is64BitProcess; //return true.
My driver is for 32bit. What I can do now, can I change the environment process. I can't install the driver for 64bit process because I have installed Office 2010 x32.
The OLEDB drivers for 32-bit and 64-bit applications are different.
If you only have the 32-bit driver installed, then 64-bit applications that attempt to use it will get this error. Similarly, if you have only the 64-bit version installed, then 32-bit applications that attempt to use it will get this error.
You say:
I try this code in other projects on my local machine and everything is working
Ergo, at least one of the two must be correctly installed.
To understand what's happening you could examine Environment.Is64BitProcess in both the application that works, and the one that doesn't. That will tell you which version is missing.
Then download and install the 32-bit or 64-bit version that's missing from:
http://www.microsoft.com/en-us/download/details.aspx?id=13255
You need AccessDatabaseEngine.exe (32-bit) or AccessDatabaseEngine_64.exe (64-bit)
Note that you may need to specify the provider as 'Microsoft.ACE.OLEDB.14.0' for the Office 2010 version (12.0 was for Office 2007).
After some hours I found a solution:
What were the steps, first I try to run the project on x86 - Properties/Build/Platform Target. Exception was thrown that I can't rebuild, because a registry was false. I create the registry. How to do it:
In notepad file paste this code and save it like reg file. Make the file name something to remember why you have it in the future(Fusion.reg).
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion]
"EnableLog"=dword:00000001
After that I had a problem because not all of my assemblies was readable by the application pool. Solution about that was going to IIS/Application Pools/Application Pool 4.0/General/Enable 32- Bit Applications. After that restart the IIS, close the project and open it again and everything was working with 32bit version.
The following Database connection code is working in one project but not for other.
Both
Reside in the same folder
Accessing the same Oracle.dataaccess dll
I am unable to understand what might have led the other project not connect to oracle DB.
I am out of ideas on how to make this project use the connection strings in the tnsnames.ora.
Any help is appreciated
Code:
string constr = "Data Source=Dev11G;User Id=Username;Password=pwd;";
OracleConnection con = new OracleConnection(constr);
con.Open();
OracleCommand cmd = new OracleCommand("Select * from Table", con);
cmd.CommandType = CommandType.Text;
DataTable dt = new DataTable();
using (OracleDataAdapter da = new OracleDataAdapter())
{
da.SelectCommand = cmd;
da.Fill(dt);
}
Error being Recieved: ORA-12154:TNS:could not resolve the connect identifier specified
Error occuring at: con.Open();
Have you tried using EZCONNECT instead of using TNS Names? TNS Names is convenient on a client (with IDEs, etc), but any time you have to deploy an application, you're dependent on whomever maintains that machine. If they update TNS names, it could potentially interfere with your application.
The connection string can be as simple as:
string conString = String.Format("Direct=true;Data Source={0};Port={1};" +
"Service Name={2};User={3};Password={4};Connection Timeout={5}", ...
If you don't know these values, you can find a machine where it's set up correctly and:
tnsping Dev11G
Thanks for all of your posts.I finally found it.it has to do with the local IIS server settings.The project that is succesfully connecting to Oracle is using visual studio development server...while the other one which is unable to connect is using local IIS server.So I have to grant the IIS access to the tnsnames.ora folder.
This post really helped me...
Oracle ORA-12154 error on local IIS, but not with Visual Studio Development Server
I wrote a console application to read the xlsx file in C# using OleDbConnection. It throws the following error
The Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
Below is the code i have written
string connString = #"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\Suganya\ColumnReport.xlsx;Extended Properties=Excel 12.0;";
OleDbConnection objConn = new OleDbConnection();
OleDbDataAdapter dataAdapter = new OleDbDataAdapter();
objConn = new OleDbConnection(connString);
string Query = "SELECT * FROM [Sheet1$]";
OleDbCommand objCmd = new OleDbCommand(Query, objConn);
DataTable Table = new DataTable();
dataAdapter.SelectCommand = objCmd;
dataAdapter.Fill(Table);
I have already performed following things to fix the issue.
I have installed AccessDatabaseEngine.exe (32 bit) and found that ACEOLEDB.dll is present in the following path C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14
Tried referring the ACEOLEDB.dll in the application. But it gave me the following error
A reference to 'ACEOLEDB.DLL' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component
The configuration platform of console application is of 32 Bit
Environment Details
Windows Server 2008 (64 bit)
Visual Studio 2010 ( 32 bit)
MS office is not installed
Checked the following links to fix the issue
1.http://www.codeproject.com/Questions/486549/Theplus-27Microsoft-ACE-Oledb-12-0-27plusproviderp
2.http://www.codeproject.com/Questions/337953/The-Microsoft-ACE-OLEDB-12-0-provider-is-not-regis
Any help is highly appreciated.
You have to install Microsoft Office; Office installation process will copy and register the wished assemblies ('ACEOLEDB.DLL') in the GAC, or you can add the missing assemblies in your bin (application) directory or regsiter them by your self.
Can someone help me out please, as google is not providing the answers.
I've got a SharePoint 2007 setup which uses SQL Server 2008 R2 SSAS OLAP cubes via some web parts.
As a C# developer, Sharepoint is a nightmare, so I decided I needed to try to get to grips with just C# and OLAP interaction. My cubes all exist, and are working, so all I needed to do was create a simple C# App to get it all straight in my mind.
I've downloaded Microsoft.AnalysisServices v10.0.0.0 and I can see it sitting happily in my GAC, but I can't add a reference from within my Visual Studio 2010 C# 4.0 project. It's just notappearing. I've tried setting the app to use 3.5, but still no joy.
Any clues?
Have you added the reference for Microsoft.AnalysisServices.AdomdClient.dll located in C:\Program Files\Microsoft.NET\ADOMD.NET\100
You could also use the nuget package manager. Type this in the console
Deprecated version (does not exist anymore):
install-package Microsoft.AnalysisServices.AdomdClient
New version:
Install-Package Microsoft.AnalysisServices.AdomdClient.retail.amd64
I think you need to reference the file directly, rather than through the GAC. It should be located in C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies
AdomdConnection steps
AdomdConnection con = new AdomdConnection("connectionstring"); // connect DB
con.Open();
AdomdCommand cmd = new AdomdCommand("MDX query", con); //query
AdomdDataReader reader = cmd.ExecuteReader(); //Execute query
while (reader.Read()) // read
{
Data dt = new Data(); // custom class
dt.Gender = reader[0].ToString();
dt.Eid = reader[1].ToString();
dt.salary = reader[2].ToString();
data.Add(dt);
}