I'm getting the exception
The underlying provider failed on ConnectionString.
with inner exception
Invalid value for key 'attachdbfilename'
on a windows 7 home premium virtual machine as i'm trying to deploy and debug my application.
However, on my development machine, the application just launches without problems.
the connection string is :
<add name="AssetsLocalDBEntities" connectionString="metadata=res://*/AssetsLocalDB.csdl|res://*/AssetsLocalDB.ssdl|res://*/AssetsLocalDB.msl;provider=System.Data.SqlClient;provider connection string="data source=(localdb)\v11.0;attachdbfilename=|DataDirectory|\AssetDatabase.mdf;initial catalog=AssetDBSource;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
Steve Wellens has mentioned that the connection string contains garbage in this topic:
The underlying provider failed on ConnectionString
yet, as Maxim Gueivandov has replied, this should valid connection string, as it's directly generated by the EntityFramework's edmx designer.
At least, i believe it to be valid, as it does work on the development machine.
Also in another topic (Entity Framework - The underlying provider failed on ConnectionString), the accepted answer is to remove the " and replace them by \", as the string is a literal in the c# code, yet i still have my connection string in xml, so " cannot simply be replaced.
on-connectionstring
The .NET version installed on the virtual machine is 4.0.30319 and MsSQL Server Express LocalDB is 11.0.2318.0, so i believe they are both up to date.
Edit: If i remove "|DataDirectory|" from the connection string i get the following error on my development machine:
Cannot attach the file 'AssetDatabase.mdf' as database 'AssetDBSource'.
So i also remove "initial catalog=AssetDBSource" and i get
An attempt to attach an auto-named database for file AssetDatabase.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
i can emagine this is because it doesn't know where to look? so, i provide it the full path (C:..\AssetDatabase.mdf) and it works.
So the remainder of the question is: how do i get relative paths working with LocalDB?
I believe the target machine doesn't have the Update 4.0.2 or later for .NET 4 installed. The .NET 4 version number can be confusing, as version 4.0.30319 seems to be used by all .NET 4 builds. In effect it does not mean your machine has the Update 4.0.2.
Can you install .NET 4 Update 4.0.3 (latest .NET 4 update as of today) on the target machine and see if the problem goes away?
Or just verify that the update is installed - just build a simple application in .NET 4 that uses SqlClient to connect to LocalDB using the connection string, and record the error information in case you still hit any errors. The EF error message is fairly generic, and I don't know how to get a detailed error from the underlying SqlClient provider.
Alternatively you could also migrate it to .NET 4.5.
Related
I'm trying to use SSIS to load some data from Oracle database to MSSQL database.
I created the project and used the ADO.Net source and was able to create a connection to Oracle and run queries and view results.
However when I actually run the package I get the following error:
Error: 0xC0208449 at Data Flow Task, ADO NET Source 2: ADO NET Source has failed to acquire the connection {EECB236A-59EA-475E-AE82-52871D15952D} with the following error message: "Could not create a managed connection manager.".
It seems similar to the issue here
And I did find that I have two oracle clients version installed "11.1" and "12.2".
One is used by PL/SQL and the other by other entity framework project.
If this is the issue I just wanted a way to tell the SSIS to pick-up the correct one.
I tried adding Entry in machine.config for "oracle.manageddataaccess.client" section with the desired version.
I also tried using other types of data sources but couldn't even create a successful connection
I tried changing the Run64bitRuntime property in the project to False
Note: I don't have SSIS installed on my machine.
Eventually, I just had to remove the entries related to 11.1 in path variable then restarted my machine.
Also I switched to "dotConnectForOracle" for connection and now it seems to be working fine.
I'm expecting issues related to other applications that might still be using the 11.1 version, but that will be a problem for another day.
Always make sure to write the user (oracle schema) in uppercase and some special characters [in my case it was $] in the password needs escape character even if you're using the wizard not the cmd
I still don't understand the whole issue but I hope this helps someone some day.
How do I configure CommandTimeout (not Connect Timeout) from connection string in SQL Server?
I thought it'd be simple to find but apparently not. Below I added CommandTimeout=60. It doesn't seem to break anything, but I have no idea if it's actually working or not (and I can't find doc on this)
Data Source=someplace.com;Initial Catalog=MyDB;CommandTimeout=60;User Id=someID;Password=secret;
It's probably worth pointing out that setting the default command timeout via the connection string is possible in Microsoft.Data.SqlClient since version ~2.1.0. This package is the open source replacement for System.Data.SqlClient and is available from nuget
If you add e.g. ;Command Timeout=300 to your connection string and receive an error Keyword not supported: Command Timeout' you should check that you truly are using Microsoft.Data.SqlClient, and that its version is greater than 2.1; the question was posed before it was possible, but times have changed
Confirm, using the versions of:
Microsoft ActiveX Data Objects 6.1 Library
Microsoft ActiveX Data Objects Recordset 6.0 Library
The CommandTimeout - when set for the Connection object - works also for the ADO Queries following Connection Open.
I made EntityFramework (6) CodeFirst WinForms application
On my machine it works fine but when I'm trying to make Installation (with VS 2015 Installing projects) of my project and to run it on another machine, I get Expansion of Data Directory failed
I'm really dont understand- when I'm trying to change db name in ConnectionString to some wrong name- it still works.
My connection string in app config:
I found what was the problem. It is not enough to pass the name of connection string via Entity context constructor :base(ConnectionString). Entity context name MUST be the same as Connection string in app config. Other way EF create some another db.
I have a simple EF 5.0 / Code First application developed in VS2012. In development it uses SQL Server CE. However, when I deployed it on a test server, I am getting the following stack of errors:
ProviderIncompatibleException: An error occurred while getting provider information from the database.
This can be caused by Entity Framework using an incorrect connection string.
Check the inner exceptions for details and ensure that the connection string is correct.
ProviderIncompatibleException: The provider did not return a ProviderManifestToken string
SqlException (0x80131904): Login failed for user 'MYDOMAIN\MYSERVER$'
IIS and the database are on the same server (MYSERVER). It's running Win2012, (with IIS 8 and .NET 4.5) and SQL Server 2012.
There are two things in web.config that caught my attention. First, connection string. I generated it from IIS UI; and I used my old connection strings that had "Data Source", rather than server. I used localhost and server name. I created a db user. I read somewhere that the database doesn't exist - so I deleted it. I gave permissions to NT AUTHORITY\NT SERVICE in the database. I probably did some other permutations - but the result is always the same.
The second place was Connection Factory under entity framework section. Apparently, it wasn't changed by Web Deploy; type was still SqlCeConnectionFactory, and parameter was System.Data.SqlServerCe.4.0. I saw somewhere that SQL Server was the default - so I deleted it; and when that didn't work, I changed the values to SqlConnectionFactory and System.Data.SqlServer correspondingly - but again, result is the same.
By now I ran out of ideas... Given that I have a problem even when I am reading the data from existing database - I am missing something simple...
I need to modify an existing Windows CE app which gets it data from SQL Compact database (sdf) to update the database table (only 1 table) with latest records from a SQL Server Express when ever it is docked to the machine.
I came across Microsoft Sync Framework and it seems to be more than capable of enabling me to achieve my requirement. I tried one of their Walkthrough: Creating an Occasionally Connected Smart Device Application, but was not able to get the app working (the app I created based on the guide as well the sample code). The WCF service is hosted successfully and I can browse to the service from the browser as well.
I am encountering an error at the below line on the click event of SynchronizeMenuItem.
Dim syncStats As Global.Microsoft.Synchronization.Data.SyncStatistics = syncAgent.Synchronize()
Below is the trace from the output window:
'MobileSyncServices.exe' (Managed): Loaded 'System.SR.dll'
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.ServiceModel.EndpointNotFoundException' occurred in System.ServiceModel.dll
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
The thread 0x771e2c1e has exited with code 0 (0x0).
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
I've been trying to find a solution for this problem as I didn't come across any after 2 days hence posting it here. I've installed all the framework/ service pack which are prerequisite for this as well. Have any of you tried this walk through and encountered a similar issue? What baffles me further is, that the sample code is also failing in two of my development machines (1 is Win XP and the Win 7).
Is there any other alternative way to update table in a Windows CE device with SQL Express Server when docked?
The requirment was to find a method to overwrite an table on a docked device (connected through ActiveSync/ Sync Center), achieved this by connecting to the SQL Server directly (by specifying either ip address) from the Pocket PC.
User would specify the SQL Server credentials Under system config/ options, which would be made use of to connect to the SQL Server. Once the desired data from the Server is broght down, the compact database is updated with the relevant data.
Below web resources paved the way to solve this issue and achieve the goal.
Connecting to SQL Server Express from a Pocket PC application
Accessing SQL Server Express from the emulator (or PDA)