Saturday, February 25, 2012

connecting through C#

When I look at the connection string it's:

Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\ProcBuilder.mdf;Integrated Security=True;User Instance=True

This works fine on my machine, but when I try to run it on another computer it tells me:

"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."

It should not be trying to connect remotely, it's a local DB. Do I

have to install SQL Express on the machine I'm installing this on for

it to work?

hi,

data is not local to the client machine but to the machine providing the service, the machine with SQL Server (SQLExpress) installed.. and, of course, the relative database files have to be stored on that pc...

so, if you have to connect to a remote SQLExpress instance, you should modify the connection string accordingly to the "remote" SQLExpress instance..
if .\SQExpress works for a local connection, a remote one should "point" to the computer name, thus ComputerName\SQLExpress, and this is a "general" thumb for SQL Server connections...

but you are also dealing User Instance facilities, and http://msdn2.microsoft.com/en-us/library/bb264564.aspx#sqlexpuser_topic8 points out only "local connections" are supported.. you can overcome this hacking the pipe the service is listening on, but you should go for a more "traditional" use of a SQL Server engine..

or, you just install SQLExpress (and your user database(s)) on every each machine and continue using User Instance feature "locally"..

regards

No comments:

Post a Comment