Problem with MsSQL Connection

G

Guest

I am currently using SQLEXPRESS as a local db file and it works fine when I
access it with C#. However, when I try move the whole application and the db
to another computer running the SQL standard edition. I keep getting the
following error message.

System.Data.SqlClient.SqlException: An error has occurred while establishing
a connection to the server.
When connecting to SQL Server 2005, this failure may be caused by the fact
that under the default settings
SQL Server does not allow remote connections. (provider: SQL Network
Interfaces,
error: 26 - Error Locating Server/Instance Specified)

Similarly, Im trying to access the db locally and remote connections has
actually been enabled altho I dun think thats the issue here. Does anyone
knows how to solve this?
 
G

Guest

Airkon,
It is important to understand the differences between SQLExpress and SQL
Server.
SQLExpress can autoattach an MDF database file from the connection string
but this only works with local connections, like for development work.

When you migrate the MDF file to a remote SQL Server, it needs to be
attached, and the connection string changed to match. You can find out about
all this stuff in the documentation.
Peter
 
J

James Irvine

Airkon said:
I am currently using SQLEXPRESS as a local db file and it works fine when I
access it with C#. However, when I try move the whole application and the db
to another computer running the SQL standard edition. I keep getting the
following error message.

System.Data.SqlClient.SqlException: An error has occurred while establishing
a connection to the server.
When connecting to SQL Server 2005, this failure may be caused by the fact
that under the default settings
SQL Server does not allow remote connections. (provider: SQL Network
Interfaces,
error: 26 - Error Locating Server/Instance Specified)

Similarly, Im trying to access the db locally and remote connections has
actually been enabled altho I dun think thats the issue here. Does anyone
knows how to solve this?


Assuming you really do have allow remote connections turned on, then maybe you just have a syntax error. Here's some working examples -one connects to SQL
Express on my local pc, the other to SQL Server my ISP:

in web.config:

<connectionStrings>

<add name="aspGuysConn" connectionString="Data Source=mssql7.aspGuysshared.com;Initial Catalog=freds_Budgets;Persist Security Info=True;User
ID=fred_b;Password=rxrgg" providerName="System.Data.SqlClient"/>

<add name="localExpConn" connectionString="Data Source=fredsPC\SQLEXPRESS;Initial Catalog=freds_Budgets;Integrated Security=True"
providerName="System.Data.SqlClient"/>


</connectionStrings>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top