Install C# application with SQL Server database

Asked

Viewed 639 times

2

I made a simple C# application using SQL Server 2008 database.

When I went to install on another computer, I came across the following error:

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.

This is because the server I am trying to install the application on is different from the one I used to create it, so the instance of connection is different. What should I do to get my program installed on other computers?

  • You have Sql Server installed on other computers?

  • @Randrade I do own!

  • SQL Server is on the same machine as the application?

  • @Randrade positive!

  • Will you install on the local machine or on a server? How are you currently setting up the connection?

  • I will install it on the local machine. The connection string looks like this: Data Source=. SQLEXPRESS;Attachdbfilename=c: data System.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True

Show 1 more comment

3 answers

1

In dev best practices with client-server database, you should store the connection string within the Web.config or App.config file. This is because, when you install the application on a second workstation, you can change this setting by editing the file to point to the database on the server.

Probably if you are already doing this, just change this connection string (connetionString) to the computer where the BD is located.

0

You will need a way to configure the connectionstring of your connection. The form of configuration depends on which component you used to make the connection to the databank. It is also necessary to free the ports of sql server in the firewall.

0

You have made an application that on each computer that is installed will need to connect to a local sql server?

If yes the best option would be you create a pro user option map the database on first access.

  • I thought that too, but is it possible to do this even if I am copying the . mdf file to the machine that will install the application? Because the bank is already created and would not like to have to recreate it every time you install on a different computer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.