So I'm running an SQL Server on my home computer [THOR].
I have a program that boots up, and then lists the SQL servers it can find.
I'm using a code called "SQLInfoEnumerator" which I found on another forum.
- I don't believe that is the issue so i haven't put that code here.
On the server (THOR) it lists (local) asthe only server (which is correct)
So I use this listed item and insert it into this string:
string lotsconstring = "Data Source=" + SQLServer + ";Database=" + "lots" + ";Integrated Security=False;User ID=sa;Password=XXXXXXX";
Now when i run it on my home computer it works, and the connection is established.
When I run it on a laptop which is connected via WIFI, it finds:
\\THOR\SQLEXPRESS
and the connection fails.
Now to test the idea that this does work in other cases, i installed my program is a business owned by a friend.
Master = "SERVER"
And it finds: \\SERVER\SQLEXPRESS
and the connection WORKS!
So in conclusion;
Program finds list List entry works for my server List entry works for a client connecting to a server in a real business network List entry DOESNT work for a client PC on my home network connecting to the server..
Anything I can try or tests to find out why the connection doesn't work?
EDIT:
Also, I have just tried on both home server and the laptop just having "Data Source = THOR"
and it works!
So home: Just the PC name works, having the instance fails At work: Having the PC name fails and having the instance there works!
EDIT 2: Exception code from the failed connection (trying to con.open())
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: 25 - Connection string is not valid)
As mentioned, if i just use THOR not \\THOR\SQLEXPRESS
it works, so it shouldnt be a matter of not allowing a remote connection
Testing:
THOR
= Works on both
THOR\SQLEXPRESS
= Fails on Laptop
THOR\\SQLEXPRESS
= fails on both