Invalid request BLR at offset 1049 - function ROUNDDEC is not defined - c#

First lets mention that I am working on some program that is already using a database from our other program which I haven't built.
So I tried to use stored procedure and here is how that procedure looks like:
↑OK
↓VRDOK
↓BRDOK
↓ROBAID
↓CENA_BEZ_PDV
↓KOL
↓RABAT
So here is my commmand:
using (var command = new FbCommand("NAPRAVISTAVKU", con)
{
CommandType = CommandType.StoredProcedure
})
{
command.Parameters.AddWithValue("#VRDOK", 33);
command.Parameters.AddWithValue("#BRDOK", 711066);
command.Parameters.AddWithValue("#ROBAID", 1040);
command.Parameters.AddWithValue("#CENA_BEZ_PDV", 0.0);
command.Parameters.AddWithValue("#KOL", 10.0);
command.Parameters.AddWithValue("#RABAT", 0.0);
FbDataReader dr = command.ExecuteReader();
while (dr.Read())
{
MessageBox.Show(dr[0].ToString());
}
}
So my question is why am I getting this error that funcion rounddec is not defined. Is that function supposed to be in database or in my program or other external file? Is there a way to create new function inside my program and call it ROUNDDEC since I know what it needs to do?
Error image link

ROUNDDEC is part of FreeUDBLib.dll and it is working with 32bit firebird. Problem was I had installed on my PC Firebird 3.0 x64, Firebird 2.1 x64 and Firebird 2.1 x86. My program was built to work for Firebird 2.1 x86, but for some reason, even if I had this DLL in x86 version ULF file, it was not pulling it from it, instead it was checking for UDFs in x64bit version. So solution was to uninstall all versions and reinstall 2.1 x86, then reinstall ddex and firebird.sql and it worked.
I think there is better way to manually set up folder for UDF, but for now I do not know so this was the acceptable solution.

Related

Application crashes on debugging a web project with exit code -2147023895 (0x800703e9) in Visual Studio 2017

I am trying to debug a web api project on a newly setup laptop with Visual studio 2017 professional edition.
It uses Target framework of .NET Framework 4.6.1.
The web application (not visual studio) crashes few seconds after starting with this in the output window.
The program '[4868] iisexpress.exe' has exited with code -2147023895 (0x800703e9).
And for every crash, I see this message in Event Viewer
The description for Event ID 0 from source VSTTExecution cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
(devenv.exe, PID 24968, Thread 1) IdleProcessorManager.DoWork - Job threw:
Invalid URI: The format of the URI could not be determined. at
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString)
at Microsoft.VisualStudio.TestTools.TestCaseManagement.SolutionIntegrationManager.IsRunConfig(String filename)
at Microsoft.VisualStudio.TestTools.TestCaseManagement.SolutionIntegrationManager.d__351.MoveNext()
at Microsoft.VisualStudio.TestTools.TestCaseManagement.IdleProcessorManager.DoWork()
The message resource is present but the message was not found in the message table
I already tried deleting .vs folder, restarting pc, uninstall/install vs, uninstall/install .net framework amongst other things.
Can someone help me fix this, unable to get to the 'real' reason for these failures.
Things to note -
1. The project works fine on other machines.
2. I can create a new project using project template and run/debug application successfully.
EDIT : On more investigation I find that the web application breaks (without any error other than the exit code) and exits.
public virtual DataSet Execute(SqlCommand sqlCommand, SqlConnection sqlConnection)
{
if (sqlCommand == null || sqlConnection == null)
{
return null;
}
var ds = new DataSet();
if (sqlConnection.State != ConnectionState.Open)
{
sqlConnection.Open();
}
using (var adp = new SqlDataAdapter(sqlCommand))
{
adp.Fill(ds); <---- BREAKS here!
return ds;
}
}
On another machine where its working, it works perfectly fine. And the SP returns around 390K records. Possible stackoverflow exception?
Please check the Framework versions that are installed to your new laptop.
I suspect that the minor versions don't match wiht your new laptop.
You can check which versions are installed to your machine via the link:
https://learn.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed
Edit:
1- Install the version from :
https://www.microsoft.com/en-us/download/details.aspx?id=49981
2- Or I recommend you to upgrade your Project's framework to .NET Framework 4.7.2

SQLite with MVC Core

I'm trying to create a database in memory and run a query with .NET Core 2.1 framework. To do this I have installed a package called Microsoft.Data.Sqlite.Core and then tried to do the following:
var connection = new SqliteConnection("Data Source=:memory:");
connection.Execute("Some Create Table Query");
And my code will crash with the following error:
You need to call SQLitePCL.raw.SetProvider(). If you are using a bundle package, this is done by calling SQLitePCL.Batteries.Init().
I've done a lot of digging to find a solution and one of them suggested calling this:
SQLitePCL.raw.SetProvider(new SQLite3Provider_e_sqlite3());
This produces me a new error:
'Unable to load DLL 'e_sqlite3' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)'
I am really lost at this point how to accomplish this. All I want to do is create an in-memory database so I can run some queries for purposes of unit testing.
I'm not sure if this is relevant but I am not using EF6, I am using Dapper and also I am using SQL Server in my actual project. I wanted to plug in Sqlite in unit tests so I can also test my queries.
I have a feeling I am using wrong packages, but looking around there are so many and I can't find any clear documentation on how to use Sqlite with MVC Core projects.
Try adding the SQLitePCLRaw.bundle_green package to your project.
dotnet add package SQLitePCLRaw.bundle_green
At that point, the following program (inspired by this) works:
using Microsoft.Data.Sqlite;
class Program
{
static void Main()
{
var connection = new SqliteConnection("Data Source=:memory:");
connection.Open();
var createCommand = connection.CreateCommand();
createCommand.CommandText =
#"
CREATE TABLE data (
value TEXT
)
";
createCommand.ExecuteNonQuery();
}
}
This is the test that I ran locally.
cd C:/temp
dotnet new console
dotnet add package Microsoft.Data.Sqlite.Core
dotnet add package SQLitePCLRaw.bundle_green
//
// paste the above program into Program.cs, then...
//
dotnet run
What is bundle_green? bundle_green is one of the Sqlite "bundle packages", which are expressly designed to ease cross-platform development. Here is a description from the official repository:
These packages automatically bring in the right dependencies for each platform. They also provide a single Init() call that is the same for all platforms... SQLitePCLRaw.bundle_green is a bundle that uses e_sqlite3 everywhere except iOS, where the system-provided SQLite is used.

OleDbConnection.Open() throws exception only in one project, same code works in other projects

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.

Running in 64 bit mode with the 32 bit Oracle Service

This question similar to link
link2
I fixed this problem, but when I opened new project Wcf service library, I had that same problem, and all this changes that I had done before did't help me.
I tried every thing that I did before and even more but it didn't helped.
It is important to say that if I do the same in another project all work fine but in WcfServiceLibrary it doesn't work.In WcfServiceApplication it working too.
I use VS2012(4.5) Win7 (64), my Oracle clien 32, but in other project this is not a problem.
Maybe it because Wcf library project i don't know.
i just buil service that save datd from database and i get error on connection to db.
Error: Attempt to load Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed.
My code
using (OracleConnection con = new OracleConnection())
{
con.ConnectionString = "User Id=zxc;Password=zxc;Data Source=NXE";
con.Open();//here i get error
OracleCommand cmd = new OracleCommand();
cmd.Connection = con;
cmd.CommandText = "select * from " + Table;
int rowsUpdated = cmd.ExecuteNonQuery();
OracleDataReader reader = cmd.ExecuteReader();
String DataFromORL = "";
int row = 0;
while (reader.Read() && row < 50)
{
row++;
if (reader.HasRows)
{
DataFromORL += reader.GetInt32(0);
}
}
}
I too got the same issue.
for me issue got fixed by doing the following thing.
prior to this check whether you have installed both 32bit and 64bit Oracle clients to make it available in both environments.
for me the reason for getting this error.
Error: Attempt to load Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64-bit mode with the 32-bit Oracle client components installed.
is because of the environmental variables has only one installation location and it is 32bit installation location that's why the error is This problem will occur when running in 64-bit mode with the 32-bit Oracle client components installed.
so, to resolve this what I did is, I added 64-bit installation location also and restarted my visual studio. if it does not work try by restarting system also, we are supposed to add both bin directories available in Oracle client installation location that we specify while installing Oracle clients. In my system location is like: 32-bit C:\app\client\<user>\product\12.1.0\client_2\bin
64-bit C:\app\client\<user>\product\12.1.0\client_1\bin

Oracle.DataAccess Error

I have an asp.net / C# web application running in a Windows environment.
The project builds fine and runs perfectly on my local machine's VB.net development server.
However, when I publish to the real application server I receive the following error message:
[OracleException (0x80004005): The provider is not compatible with the version of Oracle client]
[TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception.]
There is a version of this application currently up and running just fine, I am testing on the live server in a different directory. I even tried snagging the Oracle.DataAccess .dll from the working application but still get the same error message.
First off: The Oracle client/provider is a mess. And that goes for both the MS one (depreciated anyway) as well as the Oracle one.
In order to connect to an Oracle DB via the ODP.NET provider three things need to be setup properly:
Oracle client needs to be setup properly ( has nothing to do with the .NET provider, this referring to the installed oracle client usually in c:\oracle)
The ODP.NET provider needs to be compatible with the installed Oracle client
The architecture of client and provider and your application need to match, you cannot use the 64bit client with an x86 provider/application and vise versa
Usually the best is to have the newest version of both. But if you want to get rid of this issue once and for all use a third party oracle .NET provider.
UPDATE
One of the better ones is from DataDirect (no affiliation):
http://www.datadirect.com/products/net/net-for-oracle/index.html
It's not just installation (no oracle client necessary), but it's also faster, fully managed, x64 and general support is a way better than what you get with the ODP.NET one. It will cost you though.
The DevArt one is pretty decent as well (and much much cheaper):
http://www.devart.com/dotconnect/oracle/
We decided for the DataDirect for extensibility reasons, this should not be relevant to you however.
Here you can find a good compilation of third parties that build .NET providers, not limited to oracle though:
http://msdn.microsoft.com/en-us/data/dd363565
I came across the same scenario before
Reading this may help you some how ODAC Oracle for .NET
about your problem in your server you have to install the whole ODAC Client from oracle
the latest version now is 4.xx
i have installed it and everything works like charm
hope this helps :)
Take Care
I was able to solve this by searching for Oracle.DataAccess.dll on the prod server.
So instead of trying to build/deploy the project with the Oracle.DataAccess.dll from my development environment, I copied the .dll down from the prod server oracle client directory and included that as a reference instead. I also set the .dll properties "Copy Local = true" and "Specific Version" = true. So it looks like there is a mismatch between the oracle client version on my dev server and the prod server.
Equals, with Oracle.DataAccess.dll Works!!!!
//using Oracle.DataAccess.Client
object pdf = null;
var queryString =#"SELECT PDF FROM DIGITAL WHERE ID_DIGITAL=1001" ; //example
var ctx = new Entities();
var entityConn = ctx.Connection as EntityConnection;
if (entityConn != null)
{
var dbConn = entityConn.StoreConnection as OracleConnection;
dbConn.Open();
var cmd = new OracleCommand(queryString, dbConn);
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
pdf = reader[0];
}
}
dbConn.Close();
}
return pdf;
In addition to the other suggestions, just try running Visual Studio as administrator.
I spent a lot of time messing around with the GAC and various versions of the Oracle.DataAccess.dll, and in the end just running VS as administrator got it to run.

Categories

Resources