Unable to connect to database after publishing app - c#

Everything works fine on the computer that I built the application on, both the database and the program were created in vs2017. When I install the application on another computer that has sql but not vs installed, it gives me 'error 52 a network related issue has occurred unable to connect to local database.' How am I supposed to get it to see the database on another users computer other than my own? I was able to successfully get my app to work on a different computer that has vs and sql installed, but I dont want to install 50GB worth of excess on every computer.
Below is my connection string
<add name="ExagridEntities" connectionString="data source=(LocalDB)\MSSQLLocalDB;AttachDBFilename=|DataDirectory|Exagrid.mdf;" providerName="System.Data.EntityClient" />
I have tried publishing from visual studio by clicking project>publish and also creating a setup project where I put the mdf file in with the application files but they both returned the same error 52.
UPDATE
When I installed visual studio on one of the computers my program ran just fine. Does anyone know what package I need so I can just run the program without having to install vs?

Related

Deploying a C# application using LocalDB database

When I run my C# application on another PC, a network-related error appears. On my PC, it runs fine. I have used AttachDbFilename=|DataDirectory| to specify the location of my .mdf files. Now, what am I missing in this deployment that makes the application not to run on other PCs?
You are missing an SQL Server instance on your client machines,one option is to install LocalDB on them. Find the installation file SqlLocalDB.MSI, suitable for OS versions on your client machines, you may try this latest version https://download.microsoft.com/download/7/c/1/7c14e92e-bdcb-4f89-b7cf-93543e7112d1/SqlLocalDB.msi

Can’t open SQL .MDF file because it’s version 852

I’ve created a C# application and have published it. I tested the published application on my own computer and everything was working properly. When I installed the app on my client’s computer that has the same SQL Server version installed as mine, when I want to open the app, I get this error:
Can’t use or open database because it’s version 852
and this machine supports 706 or earlier.
I’ve installed SSMS, SQL Server Express, a higher version (2017) of SQL Server, but none of the above helped. I’m frustrated, what can I do?
My App.Config file is like this:
Data Source=(LocalDB)\MSSQLLOCALDB;AttachDbFileName=|DataDirectory|\SLApp.mdf;Integrated Security=True;
Everything works fine on my computer with the config mentioned above. Now what can I do?

Visual Studio 2017 tries to connect to Local Mysql with an IP when debugging

For some reason After a windows 10 upgrade resulting to a bsod event, I had to do a fresh install of my PC. I have visual studio 2017 and MySQL set up for my C# ASP.NET EF projects. I have installed MySQL similar to my old system and I have a laptop with similar setup which works okay.
The problem is when I try to debug the application tries to connect to the local mysql(version 5.7.23) using an IP instead of localhost and fails to authenticate.
MySql.Data.MySqlClient.MySqlException HResult= 0x80004005
Message=Authentication to host '' for user '' using method
`'mysql_native_password' failed with message: Access denied for user ''#'xxx.xxx.x.x'
(using password: NO) Source=MySql.Data'`
When I run update-database etc in the console of visual studio it connects to database alright and update tables etc. But it fails to connect when I debug the application.
I have maintained using localhost as string and changed to the IP still cannot connect on debug.
On the menu bar, choose View, Other Windows, Data Sources (or choose the Shift+Alt+D keys).
In the Choose Data Source window select MySql Database and press Continue.
in the Add Connection window, set server name: 127.0.0.1 or localhost.
Then test again using the debug to ensure it's now fixed.

C# with MSSQL database Project Not running in another computers

I have Developed a C# project using Visual Studio 2015 and in this project, I have used the Microsoft SQL Server 2017 Database System.
The Problem is When I tried to run my project's Setup in other computer it shows the following Message whenever I run the project after the installation in another computer.
I have tried installing the MS SQL server in other computer it is displaying the same message. What I have done wrong?? Please help me. How to run my project in any computer?
You are not connected to SQL server yet. Make sure that the SQL services are running correctly. You can check them by clicking on My Computer->Manage->Services And Applications->Services.

How to Deploy "SQL Server Express + EF" Application

It's my first time to Deploy an Application which uses SQL Server Express Database.
I'm Using Entity Framework Model First to contact Database.
and i created a Setup wizard with Install Shield to Install the App.
These are Steps that I'v done to Install The Application in Destination Computer :
Installing MS SQL Server Express (DEST)
Installing The Program using Setup file (DEST)
Detach Database from SQL server and Copy Related .mdf ,.ldf file to the Destination Computer.
Attach database file in destination computer using SQL Server Management Studio.
I know server names and SQL name Instances are different and my program can't run correctly with the Old Connection String.
I'm Beginner at this, and I want to know what should I do in the Destination Computer to make the program run?
should I find a way to change the connection string on runtime?!
or is there any way to modify installshield project and it do this work for me? (installshield is professional edition)
could you suggest me what to do?
in my searches I saw that WiX can do this, but I find it complicated, and i don't have enough time to learn it. i need to deploy the app ASAP.
Thanks alot.
Few hints for using LocalDB in your project:
Download SQL Express LocalDB 2014 here. You can install it silently with single command like this
msiexec /i SqlLocalDB.msi /qn IACCEPTSQLLOCALDBLICENSETERMS=YES
Include your .MDF in your VS project and set in properties to Copy if newer so that it gets copied to your bin folder during build so that it is automatically included in the installer.
At your app startup (in app.cs) check, if database file exists in desired location (e.g. %PUBLIC%\YourApp\Data) (WPF Desktop Application with MDF used locally for all local users). If not, copy the .mdf file from your app install dir to your data dir.
Modify app.config so that your connection string looks like:
<add name="MyContextLocalDB" connectionString="Server=(localdb)\MSSQLLocalDB; Integrated Security=True; AttachDBFilename=|DataDirectory|\MyDatabase.mdf; Connection Timeout = 30" providerName="System.Data.SqlClient" />
Connection timeout should be increased, since LocalDB exe is launched when you first try to connect to it.
You can also use Database.CreateIfNotExists, but I have never tried it.

Categories