I watched the tutorial at http://msdn.microsoft.com/vstudio/express/beginner/windows/tier3/begin8
and tried what the author did with C# : Made a new project, right clicked the project then Add->New Item-> SQL Database
After a few seconds I get the error:
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: 2"6 - Error Locating Server/Instance Specified)
I selected "Local and remote connections" in SQL Server 2005 Surface Area Configuration but it still doesn't work.
Any ideas?
This error can be a bit misleading and IIRC I was getting it when I was first poking around in SQL Express a few months ago. With me it was the fact that I wasn't supplying the instance name correctly when connecting to the server. It should be in the form Machinename\InstanceName. Express installs by default as SQLExpress but the people who had set this up for me installed it as SQLSERVEREXP or something like that.
|||Are you sure I even have to enter an instance name? In the video tutorial the author didn't need to do that.|||
Run sqlcmd.exe -L. It will list the name of your sql server instance to connect to. It will most likely be either 'HOSTNAME' or 'HOSTNAME\SQLEXPRESS'. By default, on the local machine, VS/SSMS use '.' which means 'HOSTNAME'.
|||
Thanks for the replies so far.
I ran sqlcmd.exe -L. It's blank though, it's just "Servers: "
But does this really need to be done though if the database will be on the same machine running Visual C#? Like I said, in the tutorial video the guy didn't even type a line of code. He just added a new "SQL Database" item to his C# project.
If it matters, I haven't done anyting with SQL Express, I just installed it, then installed C# Express and straight away attempted what's being done in the video.
Start the MMC extension services.msc, look to see if sql is running ("SQL Server (?)" - question mark is your instance name (most likely SQLEXPRESS)), and start it if necessary. Then specify HOSTNAME\SQLEXPRESS as the connection string if the question mark is SQLEXPRESS. If the question mark is MSSQLSERVER, use just HOSTNAME.|||I reinstalled everything on a separate computer and it works now. I must have messed up with the initial installation on my original PC.
Thanks for the replies.
No comments:
Post a Comment