I have often run database queries in ABBYY Flexicapture by connecting to dll methods that contained the database calls. I would like to have the ability to connect directly in the ABBYY rules, if possible. A relatively recent update added the ability to write the rules in C#, so I'm assuming it's possible to do this.
I have added System.Data as a .Net Reference in the Document Definition properties, but I get "The type or namespace name 'SqlConnection' could not be found (are you missing a using directive or an assembly reference?" when I run this line of code:
SqlConn = new SqlConnection("[My Connection String]");
I have tried adding
using System.Data.SqlConnection
above that line and it says SqlConnection does not exist in System.Data.
Has anyone had success in doing this?
Try this:
using System.data.SqlClient
Related
My goal is to expose a .NET 6.0 library to COM, in order to use it from VBA in MS Access. And to use the manifest approach rather than using the registry.
Got article "Exposing .NET Core components to COM" working, using their "COM server sample" example code.
This example however requires that a manifest file is present in the folder containing the executable. When using the COM object from MS Access we do not want to place the manifest file and other files in the MS installation folders.
The suggested solution is to create an Microsoft.Windows.ActCtx object and let that object create my COM object, using the Manifest property of the ActCtx object to specify the manifest file.
This is the part that continues to fail. actCtx.CreateObject("") gives an Invalid Cast exception, even without assignment of the result to a variable, hence it is an internal issue. No additional details, no information in the event log. Tried this in C# and from VBA.
I have a few questions:
Is ActCtx the way to specify the manifest path, or is there a better way to do this from VBA in MS Office?
The example uses a COM host, which seems to be some COM class / object factory, which in turn helps creating my COM object. As opposed to .NET Framework this COM host seems to be introduced for .NET Core; .NET 6.0 in my case. Is the COM host required? Is the simpler direct instantiation possible?
Does anyone has answers to these questions, tips, or even better: a working example?
Some progress but I am still not happy. Abandoned the ActCtx approach for a while and tried to create the COM server object of the sample directly in MS Access VBA. Added a reference to the com host, say COMServer.comhost.dll, as opposed to the implementation COMServer.dll. Created the object, simply with New. Error: class not registered. Performed a regsvr32 COMServer.comhost.dll and the sample works.
Although the sample works there are now again registry entries: the guid of the server class has been added to the registry. Regfree COM not achieved.
This is despite COMServer.comhost.dll looking promising. A tlb type library built separately and embedded in the .dll is seen by VBA: intellisense works and the object browser works. The manifest seems to be correctly embedded in the .dll too, and takes precedence over the manifest on disk.
The question remains how to avoid the regsvr32 step and make the solution working by just adding the reference to COMServer.comhost.dll, in MS Access VBA.
I have managed to make my Access work as a frontend for MySQL.
I have managed to make it work through connection string but because some specifics in code i would like to save DSN configuration as user DSN.
I have ran into one specific problem. I need to use option=3 inside my connection string because without option=3 i get error: The Microsoft Jet database engine stopped the process because you and another user are attempting to change the same data at the same time.
If i include option=3 in my connection string everything works well. The thing is, in Mysql Connector/ODBC data source configuration i do not know which checkbox/option represents option=3
The doc about this is here : Connector/ODBC Connection Parameters
option=3 looks deprecated as specified in this answer :
Option=3; corresponded to FLAG_FIELD_LENGTH (1) +
FLAG_FOUND_ROWS (2)
It looks indeed deprecated as in the doc I can't find any reference to FLAG_FIELD_LENGTH
We can thus assume that the flag you really need is FLAG_FOUND_ROWS
According to the doc, the GUI option for this flag is
Return matched rows instead of affected rows
I'm currently building a new CakePHP app with version 3.0.0-RC1, and trying to install and use the jasig/phpCAS plugin. Using this guide, I've run the following command from the command prompt: composer require jasig/phpcas
This correctly copies the jasig/phpcas files into the vendor directory of my app, but one of the other files that the guide says should be updated (vendor/cakephp-plugins.php) doesn't even exist.
I've had a tough time accessing the plugin. I want to be able to call its static methods, and I keep getting errors of the form: Error: Class 'App\Controller\phpCAS' not found. (The exact directory in the error changes depending on where I'm calling the method from.)
I don't know if this is due to not having the cakephp-plugins.php file, or if I'm not calling the plugin correctly. It's my understanding that if the plugin is loaded I should just be able to call static methods on it like this: phpCAS::methodName()
First of all jasig/phpcas is not a CakePHP plugin. And the vendor/cakephp-plugins.php file is created by the CakePHP plugin installer, so if you don't see such a file, you seem to have either not installed any plugins yet, or you are not using a recent version of the installer, as the creation of this file has been introduced just recently.
Regarding the error about the class not being found, you are missing the leading namespace separator (\phpCAS::methodName()) to access the class in the global namespace, respectively you are missing a proper import (use phpCAS;) that would make the class available in the current namespace.
In case you are not familiar with namespaces, you may want to start with: http://php.net/namespaces
I created one asp.net mvc application using linq to sql, and in the generated code it created this:
public ApowDataContext() :
base(global::System.Configuration.ConfigurationManager.ConnectionStrings["APOWConnectionString"].ConnectionString, mappingSource)
{
OnCreated();
}
Which worked well, However in my next mvc application for some reason it decided instead of looking at the web.config to look at a project resource instead... (and thus when deploying it did not work because the connectionstring was pointing to a dev server.
So to fix this I have edited the new projects datacontext to use the configurationmanager to grab the connectionstring BUT even after adding System.Configuration I cannot access the configuration manager (in my resources I can browse to the System.Configuration.ConfigurationManager and see the ConnectionStrings command, but in the code intellecence does not contain the ConfigurationManager under System.Configuration (but I can see a bunch of other methods, like ConfigurationSettings, for example)
So my questions are:
1\ Why has linq to sql objects decided to use a different method of looking up my connection string in my second project (i.e not use web.config).
2\ What is going on with the ConfigurationManager (why can't I access it?)
1&2\ The problem is that in my second solution, I have a separate project for the 'Model', and due to it not being in the .web project it does not by default look at the web.config, but in the project resources.
here is a good article how to sort this out: link text
I've used LINQ to SQL in a unit testing project to mock some test data. I've changed the database name today and consequently the LINQ to SQL code doesn't work any more. I get the following error 'System.Data.SqlClient.SqlException: Cannot open database "XXX" requested by the login. The login failed'. I've tried changing the Connection property on the DataContext in the designer but this doesn't work. I've tried changing the connection string in app.config as well but this doesn't work as well. Is there anything I missing here?
I managed to solve this problem: In opened up the .dbml file in the XML editor (rather than the designer) and found a Database element with the old database name referenced. Once I changed this then everything was OK.