How to make wpf apps on same netwrok read data from one SQL Server?

0

I have a C# WPF app running inside Visual Studio 2017 on my computer and I am using SQL Server 2014 to save/select data.

How can I run it on another Windows computer on the same network without installing Visual Studio / SQL Server? This app should read/insert data from/in my SQL Server.

I tried to using publish option, but the app isn't able to read data from my computer on other network pcs.

Also, I tried to copy bin to other pcs, but the app still isn't able to read data from SQL Server.

I already prepare SQL Server to receive a connection using the following steps on the following link:

How to run desktop application using SQL Server database on other computer connected with LAN

Also in app.config, I found the following connection string:

  connectionString="Data Source=DESKTOP-QO2VUSP\SQLEXPRESS;Initial Catalog=AJFactory;Integrated Security=True"

I Checked the Event handler from other pcs, I find the following Errors:

Application: Factory App.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.Data.SqlClient.SqlException at System.Data.SqlClient.SqlInternalConnectionTds..ctor(System.Data.ProviderBase.DbConnectionPoolIdentity, System.Data.SqlClient.SqlConnectionString, System.Data.SqlClient.SqlCredential, System.Object, System.String, System.Security.SecureString, Boolean, System.Data.SqlClient.SqlConnectionString, System.Data.SqlClient.SessionData, System.Data.ProviderBase.DbConnectionPool, System.String, Boolean, System.Data.SqlClient.SqlAuthenticationProviderManager

And the following:

Faulting application name: Factory App.exe, version: 1.0.0.0, time stamp: 0x5bdb0efa Faulting module name: KERNELBASE.dll, version: 10.0.17134.319, time stamp: 0x5ea0e53d Exception code: 0xe0434352 Fault offset: 0x001117d2

c#
sql-server
wpf
networking
asked on Stack Overflow Oct 31, 2018 by Mike Darwish • edited Nov 1, 2018 by Mike Darwish

3 Answers

1

The fact that it's a WPF application is irrelevant.

You need to change the connection string for your SqlConnection object. It will probably say something like "Data Source=Localhost" or "Data Source=127.0.0.1". This should be changed to the network name of your PC.

You will also need to check your Sql Server / Database configuration that another user has the correct access rights that this application needs.

answered on Stack Overflow Oct 31, 2018 by Peregrine
0

Be aware of security type in the connection string you have:

Integrated Security=True

works only if the two computers are in the same domain. I advise you to add UserName and Password for SQL in connectionString

answered on Stack Overflow Nov 1, 2018 by Husam Zidan • edited Nov 2, 2018 by Mike Darwish
0

You need to set Integrated Security=False then When it false,you need to specified the User ID and Password in the connections string, For more info about Integrated Security, Check the following Answer:

What is the difference between Integrated Security = True and Integrated Security = SSPI?

answered on Stack Overflow Nov 5, 2018 by Mike Darwish • edited Nov 6, 2018 by Mike Darwish

User contributions licensed under CC BY-SA 3.0