SqlConnection.open() throws TransactionException 0xe0434f4d - sqlconnection

Code works fine when connecting to a sql server 2005 dbase. but when connecting to a sql server 2008 dbase it fails.
scenario:
Webservice first connects to 2008 dbase fine. Then during a call in a COM+ object, the connect fails.
Recently upgraded projects to use VS2008 and upgraded to Sql Server 2008.
using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionTimeOut))
{
using (SqlConnection sqlConnection = new SqlConnection(DataConnection))
{
try
{
String command = "my_StoredProcedure";
using (SqlCommand sqlCommand = new SqlCommand(command, sqlConnection))
{
sqlConnection.Open(); //- exception is throw right after this call in the COM+ object.
Any Ideas out there?

It looks like you are missing handling a SQLException
http://blogs.msdn.com/tess/archive/2006/04/27/584927.aspx

In my case, binaries deployed to many PC's in network were executed fine except of few machines. All exceptions in code were handled but despite of that, 0xe0434f4d was thrown right after start. The app always was launched locally (not from network share), no obvious issues with permissions etc. The app had .NET 3.5 among its requirements.
I examined installed .NET version (well-known registry subtree HKLM\SOFTWARE\NET Framework Setup\NDP) and found that subkey v3.5\SP (ServicePack) is NOT at 1. It means that .NET 3.5 is installed, but not the latest released version (SP1). After downloading v3.5 SP1, installing and restarting the PC, the entire problem disappeared. So the key was "not just any .NET 3.5, but latest .NET 3.5 must be present".

Related

Getting "Could not create SSL/TLS secure channel." on Windows Server 2012 R2

The following code runs just fine on my development workstation (Windows 10 Pro), running in Visual Studio. As you can probably guess from the naming convention, I am using WebClient to post to a remote https:// endpoint.
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
resp = m_WebClient.UploadValues(m_WebClient.BaseAddress, "POST", postParams);
However, when I deploy it to my production server (Windows Server 2012 R2 Datacenter - it's an Azure VM), I am trapping the following exception:
The request was aborted: Could not create SSL/TLS secure channel.
at System.Net.WebClient.UploadValues(Uri address, String method, NameValueCollection data)
at System.Net.WebClient.UploadValues(String address, String method, NameValueCollection data)
at rater8.ReviewShake.Request.Processor.TryGetRESTApi(Int32 CompanyId, String ScrapeString, String LastJobId, String& Response)
I know that I am capable of communicating from my production server to the remote server because I've executed the call in Postman from the production server. I receive a 200 - OK. I know the remote server insists on TLS1.2, because if I disable that protocol in Postman, the call fails.
This is production code which has been running until just a couple of days ago. I will contact the vendor, but support can be spotty. In the meantime, does anyone have any ideas? Is there something which I need to configure at the OS level in order to enable this on Windows Server 2012? (I do have Windows Update running.) Thanks!
Since posting, I've accumulated two additional facts:
Switching over to HttpWebRequest did not have any positive effect.
Moving the executable over to another Windows 10 Pro machine did have a positive effect, the connection was successfully established.
So the critical combination of factors here which cause this to break is the combination of Windows Server 2012 R2 and my C# code (WebClient or HttpWebRequest). Recall that Postman was able to establish communication from the Windows Server so that, in and of itself is not the issue. Must be some esoteric handshake issue, but I'm running out of ideas. Thanks for any advice which you can provide!
Currently dealing with the same thing. We were running a web api call on a 2012 R2 server, it was working but all of a sudden, it stopped working around the time of your post.
I would assume that this is a bug with Microsoft, however here are the current solutions that I am testing that make sense.
Try another server install version, we noticed it was working with a 2016 server
I've noticed that this issue generally came to fruition when microsoft released a new VS 2019 Update, maybe try another editor or downgrade your vs2019 ide?
Maybe try downgrading your .NET framework version to something a bit more stable.
These are things I am currently testing, but the most definite one that is working is getting an install of 2016 server or 2019. Spinning up a new server install for short term period until the issue is fixed, might just be up your alley.
Edit:
At this time, the move to a updated server seems to have fixed the issue.

.Net Core 1.0, EntityFramework (SQLite), on IIS, which Windows user to give write permissions to

I'm stuck with a .Net Core 1.0 project I'm not allowed to update to the newest .Net Core version yet, and currently trying to deploy it to a development IIS (8.5, on Server 2012 R2).
Slowly working through the list of errors now… and I've come across a strange case with an sqlite database the service uses internally.
The project has a postpublish step that grants write permissions (to IIS AppPool\DefaultAppPool on the machine running the IIS) for a few files the service needs to be able to write.
All but the sqlite file are writeable from the service afterwards, and are correctly being updated.
For the sqlite database however it throws a SqliteException SQLite Error 14: 'unable to open database file', unless I give Full Access not only to the DefaultAppPool user mentioned above, but Everybody—so to me it looks like the EF code is executed in another user context than the rest of the service.
Does anyone know which user, or how I could best find out (or what else might be the problem)?

Issue with ADO.NET plus SQL Server Compact 3.5 database

I'm now using SQL Server Compact 3.5 as my local database (in order to make it compatible and running on PCs without SQL Server installed). And I tried to use ADO.NET and Entity Framework to write connection services. However, I found some issues, for example I was trying to save a new object, it looks succeed, but it's actually not really going into the database. I feel it's like just storing in memory or something (when I re-run the project, the data is still there but it's not in the database).
My environment is: SQL Server Compact Edition 3.5 + Visual Studio 2010.
EF code should be correct and is quite simple:
using(TestEntities te = new TestEntities()) {
SystemUser su = new SystemUser();
su.id = 1;
su.name = "123";
te.AddToSystemUsers(su);
te.SaveChanges();
}
I used the same code but with the database in SQL Server Management Tools, it works fine.
Can someone help me explaining with this? Is there any ways to solve the problem?
Big thanks in advance!
You have included the database file as content, and each time you debug, it is copied to the bin/debug folder. To solve this, I recommend using a full path in your connection string.

Creating a linked server from SQL Server 2008r2 to Access 2003

I've written a web app in ASP.NET that stores all of it's data in SQL Server 2008r2 and runs everything via stored procedures. The app is collecting data for a department who wants 2-3 pieces of that data pushed to an old app they use which has a Microsoft Access 2003 backend (.MDB file). My thought was to create a linked server to Access so my app can push everything to SQL server and it can handle it from there (seemed simple enough). Based on info from MSDN (here and here), I was using the following SQL command to create the linked server:
EXEC sys.sp_addlinkedserver #server = N'CMPtesting' ,
#datasrc = N'\\srv.local\SHAREDOCS\MPS\CMPdata.mdb' ,
#srvproduct = N'Access' ,
#provider = N'Microsoft.Jet.OLEDB.4.0'
This completes successfully, and I can see my CMPtesting server listed under Server Objects -> Linked Servers. However, if I try to verify the server using this:
SELECT name FROM [CMPtesting].master.sys.databases
or even just view the tables, I get an error:
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' cannot be used for distributed queries because the provider is configured to run in
single-threaded apartment mode. (Microsoft SQL Server, Error: 7308)
Researching that error led me to "SQL to Access linked server" which suggested installing some different Access drivers and then using #provider = N'Microsoft.ACE.OLEDB.12.0' instead of the Jet driver. Again, this completes successfully, but attempting to view the tables produces a different error:
Cannot create an instance of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "CMPtesting". (Microsoft
SQL Server, Error: 7302)
I know this is not simply an invalid driver error, because if I just make up a provider name I get this instead:
The OLE DB provider "foobar" has not been registered. (Microsoft SQL Server, Error: 7403)
I'm not sure what else to try because all my searches just turn up more rehashing of how to run sp_addlinkedserver without any additional details or help with these errors.

During Open(), SqlConnection.ServerVersion throws System.InvalidOperationException

When running a webservice, web page that knows how to respond. The service connects to a dbase. During the sqlconnection.open call, ASP .NET code throws the following exception:
sqlConnection.ServerVersion' threw an exception of type 'System.InvalidOperationException'
NOTE: I'm running this on my dev machine. When it runs on live web server, all is well. It is unique to my system.
I'm I missing a configuration setting with Sql Server 2008?
NOTE: recently upgraded from Sql Server 2005 to 2008
This could possibly be caused by a difference in your web.config between the live server and your dev machine. Have you checked that the connection string is properly specified?
Found problem. There was a space in the front of the connection string.