I have a .NET 3.5 C# library that uses OleDb to pull data from an Excel file and return it in a DataRowCollection which is used by a CLR Table-Valued Function in SQL Server 2005.
The function works fine when I use SELECT on it. But if I want to use its output as a source for an INSERT INTO a table, I get the following error:
System.InvalidOperationException: The ITransactionLocal interface is not supported by the 'Microsoft.Jet.OLEDB.4.0' provider. Local transactions are unavailable with the current provider.
System.InvalidOperationException:
at System.Data.OleDb.OleDbConnectionInternal.EnlistTransactionInternal(Transaction transaction, Boolean forcedAutomatic)
at System.Data.OleDb.OleDbConnection.Open()
at GetExcelFunction.GetFile(String strFileName)
at GetExcelFunction.InitMethod(String strFileName)
So, how do I solve this? Do I stop the connection from creating the transaction? If so how? I don't see any relevant methods or properties on the OleDbConnection. Is there a parameter in the connection string?
add ";OLE DB Services=-4" to connection string.
Related
I want to access an encrypted SQL Server Compact Edition database via VBA. I can access the database fine when it is not encrypted, but the code breaks when I try to use a password:
pConn.ConnectionString = "PROVIDER=Microsoft.SQLSERVER.CE.OLEDB.3.5;Password=[my_password];Data Source=" & SdfPath
I've been following the connection string example provided here for SQL Server Compact with a password:
Encryption enabled
Use this connection string to enable encryption on the database.
Data Source=MyData.sdf;Encrypt Database=True;Password=myPassword;
File Mode=shared read;Persist Security Info=False;
The Encrypt Database="True" pair is really not necessary as the presence of the Password-parameter itself turns on encryption for the connection.
But why doesn't this work in Excel VBA 2010?
Apparently, the connection string example in the site I was using is incorrect. I found the correct connection string example from Microsoft:
Using Microsoft ActiveX® Data Objects for Windows CE (ADOCE), Microsoft ActiveX Data Objects Extensions for Data Definition Language (DDL) and Security (ADOXCE), or the Replication object
To create a password-protected database using the either the ADOCE or ADOXCE Catalog object, or the AddSubscription method of the SQL Server CE Replication ActiveX object, you must specify the provider-specific SSCE:Database Password connection property in the connection string. For example:
"Provider=Microsoft.SQLSERVER.OLEDB.CE.2.0; data source=\NorthWind.sdf; SSCE:Database Password=[myPassword]"
And so now my code is:
pConn.ConnectionString = "PROVIDER=Microsoft.SQLSERVER.CE.OLEDB.3.5;SSCE:Database Password=[my_password];Data Source=" & SdfPath
This worked perfectly for me.
If you have SQL Server Compact 4.0 installed and use "Microsoft.SQLSERVER.CE.OLEDB.2.0" or "Microsoft.SQLSERVER.CE.OLEDB.3.5" as provider in connection string, you will get an error mentioning provider not found. Change connection string to reflect to "Microsoft.SQLSERVER.CE.OLEDB.4.0".
I'm getting this error when trying to use ReportingService2010:
Unable to resolve symbol 'ExecutionInfo'
ExecutionInfo and ExecutionHeader worked in ReportingService2005. I'm using Visual Studio 2010, VB.Net, and ReportingServices2010. I can connect to the server and do things like rs.ListChildren.
Any Ideas?
I found the answer to my question. Hopefully this helps others.
There are two main type of endpoints in the Report Server web service, one for Management and one for execution.
The management endpoints are: ReportService2005, ReportService2006, ReportService2010
The execution endpoint is: ReportExecution2005
Therefore you can get report names, paths, data sets, etc. from ReportService2010, but to execute a report you must use ReportService2005.
So here's how you do it:
Add a web reference to the 2005 wsdl of your server, not 2010. So do this: http://<your server>/reportserver/ReportExecution2005.asmx Not this: http://<your server>/reportserver/ReportExecution2010.asmx
Import the referenc
Create an instance of ReportExecutionService: Dim rs As New ReportExecutionService. That is the 2005 executation service that has the ExecutionInfo and ExecutionHeader methods.
Reference: http://msdn.microsoft.com/en-us/library/ms155398.aspx
This the scenario have. There's an SSRS server that has a report where the datasource is of type XML and it uses windows authentication, nothing else to it. Inside the report there's a dataset that uses that data source with this for a query "=Code.ReportUser.GetListOfItems()". This calls a method in the custom assembly that connects to the database and returns data in a string formated like this (angle brackets changed to curly for read
"<Query><XmlData><Items>" + xmlDocument.DocumentElement.InnerXml + "</Items></XmlData></Query>"
where sql datatable is written into the xmlDocument. If I go to the reporting server through an IE and run the report everything works as it should. The Problem occures when add this link to Zangle application which runs it as "IEHOST.app 'report's url'". I believe its a foxpro app that opens a browser object and report fails on the dataset that uses my xml data source. There's no question about url or reports correctness because it functions in a different environment.
This is the server error i get:
library!ReportServer_0-8!ca0!02/24/2012-10:18:45::
Call to GetPermissionsAction(path to my report).
library!ReportServer_0-8!e68!02/24/2012-10:18:45::
Call to GetSystemPropertiesAction().
library!ReportServer_0-8!e68!02/24/2012-10:18:45::
Call to GetPropertiesAction(path to my report, PathBased).
library!ReportServer_0-8!10bc!02/24/2012-10:18:45::
Call to GetSystemPermissionsAction().
library!ReportServer_0-8!e68!02/24/2012-10:18:45::
Call to GetSystemPropertiesAction().
processing!ReportServer_0-8!10bc!02/24/2012-10:18:45::
e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: ,
Microsoft.ReportingServices.ReportProcessing.ReportProcessingException:
Error during processing of the CommandText expression of dataset ‘Items’.;
processing!ReportServer_0-8!10bc!02/24/2012-10:18:45::
e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: ,
Microsoft.ReportingServices.ReportProcessing.ReportProcessingException:
Cannot set the command text for dataset 'Items'. ---> Microsoft.ReportingServices.ReportProcessing.ReportProcessingException:
Error during processing of the CommandText expression of dataset ‘Items’.
at Microsoft.ReportingServices.OnDemandProcessing.RuntimeDataSet.RunEmbeddedQuery(Boolean& readerExtensionsSupported, Boolean& readerFieldProperties, List`1 queryParams, Object[] paramValues)
--- End of inner exception stack trace ---;
I'm not sure what this means exactly. Any thoughts? it looks like a permission issue but i don't understand where. I did try to change xml data source authentication from windows to none and then add my AD account as an execution user on the reporting server. This didnt' change anything still working from browser but from Zangle browser object. One more thing, server requires authentication and all the report regardless of the environment promt for login and successfully authenticate so my credentials seems to pass to the server and only my xml data source is throwing an error when launched from with Zangle. Please share your ideas. I'm a programmer but I'm not too server stuff savy and I'm new to SSRS. Thank you.
Resolved. Turns out that foxpro app lowercases everything and the name of the sql server passed to the assembly doesn't match the name stored in the assembly. Silly :) So we'll be lowercase comparing everything from now on.
My coworker wrote a package in VB.NET to manipulate strings. I have been asked to implement them through CLR. The package accesses a reference database on the same server as the CLR dll file deployed to standardize the strings. I imported the package to my CLR code to create the functions for SQL Server.
After I deploy the dll file to sql server, the functions work fine except occasionally I get the error
System.NullReferenceException: Object reference not set to an instance of an object.
I have to execute my query several times to make it work. It seems the table is locked or sleeping. My query is like
SELECT EMAIL_ADDRESS, dbo.ufn_getEmailDomain(Email_Address) AS EDOMAIN FROM CONTACT_TEMP
WHERE Email_Address IS NOT NULL AND Email_Address<>''
dbo.ufn_getEmailDomain is the CLR function.
There is no online access to this server at all. I searched for a while and couldn't find why this error comes up occasionally or how to fix it.
Your feedback is greatly appreciated.
my CLR functions here.
<Microsoft.SqlServer.Server.SqlFunction(DataAccess:=DataAccessKind.Read)> _
Public Shared Function ufn_getEmailDomainSLD(ByVal email As String) As String
If email Is Nothing Then
Return Nothing
End If
Dim de As New DataEmail(email)
Dim dm As New DataDomain
Dim emailDomain As String
dm = de.Domain
emailDomain = dm.SLD
Return emailDomain
End Function
If I understood right - function returns domain name from email string.
Try to get it in such a way (if there are not milti-mail string values)
SELECT
EMAIL_ADDRESS,
SUBSTRING(EMAIL_ADDRESS, CHARINDEX('#', Item)+1, 2147483647) AS EDOMAIN
FROM CONTACT_TEMP
WHERE Email_Address IS NOT NULL AND Email_Address<>''
and - find your bug in your clr code. Try to recreate function with option RETURNS NULL ON NULL INPUT. If it is not help - then you need to review and to clean your CLR code.
I found the reason eventually. In the connection string in the CLR code, I should set ENLIST=FALSE because it connects to a different database. Once I set ENLIST=FALSE, the problem seems to be fixed.
I'm using an application called Logi info. it requires a connection string to my oracle database. the connection works fine but in order to configure the connection to recive ref cursors from the database, I apparently need to add PLSQLRSet=1 to the end of the string. when I do that I recieve an error "invalid connection string"
Here is my connection string without plsqlrset=1
Data Source=SID; User Id=username; Password=password;
My concern is that PLSQLRSet=1 might be .NET paramater only. Can anyone shed some light on the issue.
Thanks
It appears that the PLSQLRset option is a feature of the OraOLEDB provider (per http://download.oracle.com/docs/cd/B10501_01/win.920/a95498/using.htm).
Therefore I would guess that you have to add Provider=OraOLEDB.Oracle to the connect string -- as shown in the screenshot on the page you linked to -- in order to use this option.