(I've found lots of related posts, but still can't get my code to work in my particular situation. Also, I'm not new to SQL Server -- just to using SQLExpress in VS Express 2013.)
I've installed VS Express 2013, along with (I believe) SQLExpress. In the query editor I can do 'SELECT @@SERVERNAME' and get the following:
RICHARD-PC\LOCALDB#836BEFF7 (although the number seems to change occasionally; not sure what that means)
So I've tried every combination I can think of in the connection string:
cn.ConnectionString = "Server=RICHARD-PC\5836BEFF7;Database=BrightStar;user=root;password=root"
cn.ConnectionString = "Server=5836BEFF7\RICHARD-PC;Database=BrightStar;user=root;password=root"
cn.ConnectionString = "Server=localdb\RICHARD-PC;Database=BrightStar;user=root;password=root"
cn.ConnectionString = "Server=RICHARD-PC\localdb;Database=BrightStar;user=root;password=root"
also "#" in front of the hex number, and parens around 'localdb'.
I keep getting this error when trying to connect:
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. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Obviously, the server is there, since I can access it via the query editor. What (!) is wrong with my connection string? I've tried numerous other values for the Server parameter (based on info gleaned from various websites; all give the same error. Of course, I haven't even gotten to what the root user ID and password are. Any suggestions there (if 'root' and 'root' are wrong) would also be greatly appreciated.
(Please excuse the font problems. I couldn't figure out what was going on with that.)
Richard Ezell