WPF / local SQL Server CE 4.0 / Underling provider failed on open - c#

I have WPF application that is using EF6 with local SQL Server Compact Edition 4.0 database.
I’m using private deployment for SQL Server Compact Edition.
Application works without any errors on 99% of the workstations but I’m encountering a problem on the single one.
When I launch the application I receive MessageBox with below error:
“Underling provider failed on open”.
The error is thrown by the system (as I don’t have any MessageBox in my code) when I try to initialize Entity Framework data context.
I have found that when I run application “as an administrator” the problem doesn’t occur.
Another thing I have noticed that when I run as an administrator on that laptop it takes a almost minute to load.
The only difference between environments that I can find is that on the not working laptop there is SQL Server Express 2012 installed.
Do you think it can have any influence on my application? Could be some DLLs conflict?
*edit
I have installed SQL Server Express 2012 on the different machine and my application is working without problems. So I'm not sure if that's the reason.
Regards,

Related

How to create install package for app using local SQL server database

I wrote a small app to learn more about SQL and experiment with Entity Framework. On first execution, my app creates the database locally, and after that opens the existing database. So far, so good - it works pretty well on my laptop, which has SQL Server 2017 installed.
I tried copying the assemblies to my desktop machine and that also worked as expected, though SQL Server was not installed.
But when I tried copying the assemblies to another laptop, the app would not run. The exception I saw was:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The Server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections. (provider: SQL
Network Interfaces, error: 52 - Unable to locate a local Database
Runtime Installation. Verify SQL Server Express is properly installed
and that the Local Database Runtime feature is enabled.)
All machines are Windows 10. (Is it significant that the desktop machine has Visual Studio 2019 installed?)
I can't seem to find a post here which speaks to my problem. (I'm probably not phrasing my query well...)
Anyway, I don't want other users to be required to install SQL Server (Express, or otherwise). What do I need to include in my installation?
Can it be done more-or-less automatically by using ClickOnce deployment (a.k.a. Publishing Wizard)? Or do I need to build an .msi with Wix code?
Is SQLite a better option for this? Users of my app will not be sharing databases; each will have their own.
I have seen mention of SQL Server Compact Edition in this post: ASP.NET MVC - Switching from SQL Server Express to Compact Edition - Connection Issue, but when I tried to run this down, it seemed like this is no longer available from Microsoft. And I believe I'm already using SQL Server Express (looks like this is confirmed by the error message, above)...
At present I have worked around this problem by using ClickOnce deployment. In the near term, I would like to change the installation to include the dependencies (.NET & SQL runtimes) in the setup package, rather than downloading them at install-time.
But I wonder if SQLite would be a better long-term solution... One thing I have appreciated about SQLServer is that I can use SQLServer Management Studio to get at the database apart from the app, so I can validate what the app has done. I also think this is a good thing for users, as they will always have a second option for getting their data, if something goes wrong with the app.
Does SQLite provide any tool similar to SQLServer Management Studio for accessing the database?
SQLite is a better option as it is an embedded database. This means that it is a part of your application and doesn't require additional setup. It works well for storing per-user data that is not shared.
https://www.sqlite.org/whentouse.html
SQLite only requires its assemblies for deployment.
SQLite deployment for .net application

Can not figure out, how local SQL Servers are installed and get connection string to them

I am trying to connect to a local SQL Server database (currently installed Microsoft SQL Server 2017 as shown in the screenshot) with C#. I've searched for about some SQL Server clients for C#, but in every tutorial or guide, there are always connection strings as a constant (can not figure out how to get it).
Some details:
Platform: Windows 10 - x64 bit
SQL Manager: Microsoft SQL Server Management Studio v18.2
IDE: Microsoft Visual Studio 2019
In addition: Can you guys tell me, how can I create new server? (I figured out that, creating new SQL Server on local machine is done by installing new SQL Server software or something?) I am so confused, because once, I had tried to uninstall some SQL Server softwares from the control panel, and suddenly server has disappeared. Any suggestions how can I install my own server for example? With name, that I want to call it.

How to deploy application to many users

I have got a C# .NET application which uses an SQL Server 2008 R2 database.
I have no problem deploying the actual application to multiple PCs, however I am having a whole world of trouble deploying the database. The application is going to be used by a large amount of users - it can be downloaded and installed by anyone. My problem is that the application uses a connection string to connect to the database.
How am I going to include the database as part of the installation using the Visual Studio publish tool, and make sure that it will work on any installation with the same connection string.
I have spent a long time searching, and have tried out many potential solutions, including this, however in the latter particular case, the application could not find the database when it was deployed.
As per your given SQL connection, it seems your are using Sql Server Express edition, to bundle express edition with your application, here are the options,
Add SQL Server Expression edition setup in your installation media, and invoke setup.exe through your setup program
Or you can use Web Platform Installer
Or you can simply check in your setup program, whether desired SQL Server Express Edition is installed, if NOT then display the message to user that "Please install the Sql Server Express Edition", and guide how he/she can install, for example providing a download link
Or you can go with Sql Server Compact Edition which is a light weight version and I think only few DLLs are required to make it functional on end user's PC.
For more information:
Sql Server Express Edition:
http://blogs.msdn.com/b/user_ed/archive/2012/12/09/how-to-embed-sql-server-express-in-an-application.aspx
Sql Server Compact Edition:
https://msdn.microsoft.com/en-us/library/aa983326(v=vs.140).aspx

Visual Studio 2010 SQL Developement Server stopped working

I was making minor modifications to a view in my ASP.NET MVC 3 C# application when all of a sudden the application would no longer run. The error message is as follows:
System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Shared Memory Provider, error: 40 - Could not open a connection to SQL Server)
Upon close inspection of the server explorer I noticed that all database connections are no longer working. I cannot expand any of the connections to view the tables and data I previously generated within. When I attempt to, there is a pop-up window that is generated that repeats the exact same error as above.
It is important to note that I was not making any modifications to any portion of the application that pertains to a database. I was rearranging some of the visual components of a view in my application when all of this occurred. I had just recently restarted my computer and had made no other modifications since that time.
At first I thought that somehow SQL Express had overwritten my development environments version of SQL Server and began to reinstall SQL Server Express. The installation fails every time now. There is no specific error. Windows generates an error message saying that the setup application "stopped working" and hangs until closed.
I have tried several different versions of the SQL Server Express installation package, and they all result in the same error happening at different points in the installation process. To be clear, I'm not even sure SQL Server Express is the problem. I don't know why it would be since I'm using the SQL Server edition that is built into Visual Studio 2010.
Is the SQL service running? Check under SQL Server Configuration Manager.
Yes, another life saved.
Run-sqlservermanager11.msc, right click and start.
Is the SQL service running? Check under the SQL Server Configuration Manager.
I assume you've already tried to repair install, to uninstall and to restart your computer, pray then try again?
Are you databases remotely deployed? Because it is possible that the network is down.
Secondly, check in the we.config file if you have specified the correct credentials. Try to log in through SQL Server Management Studio.
One more thing: Stop the SQL Server service, and start it again. Or you can reboot the system.

Setup Program for Windows Service C# How to add Sql Database's

I've written on visual studio 2010 a windows service. I create all database on vs2010, where I've created a setup program for windows service to install it. My problem is I can not put my database to setup program, so that my windows service gives error on sql-database's. (At debug mode there are no problems, win. service works fine)
How can I fix this or what do I miss ?
You only have the right to redistribute SQL Server Express, see Distributing SQL Server Express. This is typically achieved by embeding the SQL Server Express install in the applicaiton distirbution Setup, see Embedding SQL Server Express into Custom Applications. For every other version of SQL Server the customer running your application must purchase a SQL Server license and install it, or configure your application to run with an existing instalation.

Categories

Resources