Tuesday, August 01, 2006

Error connecting to database

Are you getting this error?

Sqlcmd: Error: Microsoft SQL Native Client: 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.

The default solution is here:

http://support.microsoft.com/?kbid=914277&SD=tech

But what if this doesn't work? Or you're not using SQL Server 2005? Or you don't have access to the database and want to try a local solution first?

First:

Disable Simple File Sharing on your computer:
http://compnetworking.about.com/cs/winxpnetworking/ht/winxpsfs.htm

If that doesn't work, try adding the port number to your connection string. For example, change:

servername

to:

servername,1234

also, if you are connecting to a local database try changing the data source in your connection string from:

(local)

to

.\SQLEXPRESS

(This may be true even if you are not using SQLEXPRESS but have it installed on your machine, or used it at one point)

Hope this helps!

No comments: