Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I made a program, using c# and sql server with sql authentication. It works properly in my device, but after making the program setup file .exe extension using Innosetup, I cannot connect to my database.

I've have tried exporting my database in script, and run the script on another device but it does not work. I think I need to create port or something to connect to this database, or in my app.config change the server name

Here is my Connection String

    <add name="MarketDatabaseEntities" connectionString="metadata=res://*/AmanjCenter2Entity.csdl|res://*/AmanjCenter2Entity.ssdl|res://*/AmanjCenter2Entity.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=RABAR;initial catalog=MarketDatabase;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
share|improve this question

closed as off-topic by swasheck, Max Vernon, ypercubeᵀᴹ, Mark Storey-Smith, RolandoMySQLDBA Nov 17 '13 at 2:01

If this question can be reworded to fit the rules in the help center, please edit the question.

What version of SQL Server are you using? – Max Vernon Sep 16 '13 at 14:44
Im using Sql Server 2012 – rabar kareem Sep 16 '13 at 15:01
This question appears to be off-topic because it is about code. Belongs on StackOverflow – swasheck Nov 16 '13 at 16:41

You may need to use SQL Server Configuration Manager to enable TCP/IP connections.

The default is disabled, as below. You must enable TCP/IP to allow remote connections to the SQL Server machine.

enter image description here

share|improve this answer
You mean , I dont need to change server name in app.config , or creating user with same app.config username and password?? – rabar kareem Sep 16 '13 at 14:49
App.config certainly must be correctly configured with the server name. Instance name (if using a named instance), the port (if not using 1433), username, password etc. – Max Vernon Sep 16 '13 at 18:59

As shown in Max Vernon's screenshot in his answer, you must allow TCP/IP connectivity for remote connections.

Also, if you are not allowing traffic to the default instance (TCP 1433) that would also prevent connectivity.

If you are trying to connect to a non-default (named) instance, you must have the port for that instance open as well. If your connection string for the non-default instance uses port number, that should suffice, however if you are using the name of the instance in the connection string, you must open UDP 1434 and ensure that the SQL Browser service is started.

Disabling windows firewall and testing might help shortcut troubleshooting - if it works with firewall disabled, you know it's in port openings.

share|improve this answer

This Code saved my life

connection string = "Integrated security=True; data source=localhost\SQLEXPRESS; initial catalog=MarketDatabase"

This works for any device with Windows Authentication

share|improve this answer
Glad you simply needed a connection string. – Max Vernon Sep 17 '13 at 22:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.