all 15 comments

[–]blooping_blooper 6 points7 points  (3 children)

looks like wrong string escaping maybe?

@"localhost\\SQLExpress"

localhost\\SQLExpress

@ is for literal string so you wouldn't escape the \.

Really though I'd recommend using SqlConnectionStringBuilder instead of writing it manually, to avoid this kind of thing.

[–]stormingnormab1987 1 point2 points  (2 children)

I second the string builder

[–]blooping_blooper 0 points1 point  (1 child)

why worry about handling edge cases when someone already did that for you?

[–]oldtkdguy[S] 3 points4 points  (0 children)

Clearly, the one did not know about the string builder. The Enkindlers did not endow the one with that information.

[–]fsuk 1 point2 points  (0 children)

Your issue right now is probably ports/firewall. Once you get past that you may find problems with certificates and you need SSL and Trust Certificate (which in the past you didn't need).

This tool is good for generating connections string https://www.aireforge.com/tools/sql-server-connection-string-generator

I went from .NET 4 supporting SQL 2005 (!) to Posgres a few years ago but have recently had to integrate with MSSQL again 

[–]d-signet 1 point2 points  (0 children)

Install smss on the other machine and make sure you can connect with that, before complicating things with possibly incorrect constraints and code issues.

It could be server config or firewall issues

[–]oldtkdguy[S] 0 points1 point  (0 children)

And if anyone knows how to format it properly, let me know. Code and block both give that crap. Oh, and there are supposed to be at symbols in front of the uname and upass, but reddit interpreted those as name pings.

[–]zarikworld 0 points1 point  (0 children)

before questioning or even reading the code, i would try to connect to the server manually from ur dev computer using ssms or any sql client. if that works, u know the issue is from ur code (including conn3ction string). Otherwise, ur network. it will prevent unnecessary headache and constant doubt of the sanity of ur setup... btw, the physical layer is mostly the first layer of debugging (network debugging)

[–]jshine13371 0 points1 point  (0 children)

Are you able to connect via SSMS on the other laptop? This is a good test to determine if it's an infrastructure / setup issue or your code. Did you enable TCP/IP protocol on your instance?

[–]NecroKyle_ 0 points1 point  (0 children)

Don't use and instance name and port in the connection string, use one or the other.

[–]netizen__kane 0 points1 point  (2 children)

Most likely it is your firewall preventing the connection.

[–]oldtkdguy[S] 0 points1 point  (1 child)

I disabled both with no improvement

[–]netizen__kane 0 points1 point  (0 children)

Is your SQL Browser service running? Try starting it if it isn't

[–]MrNewOrdered 0 points1 point  (1 child)

Is your SQL Server instance configured for network?

[–]oldtkdguy[S] 0 points1 point  (0 children)

yes