Forum Discussion
Problems with connection string for SQLserverexpress 2019
Hi
I am looking for help please. I am new to sqlserverexpress 2019 and experimenting at the moment to get familair with the system.
I have created a sqlserver using all the defaults on my local machine. I can access sql using SSMS19 no problem. I program in visual studio vb.net and i am trying to connect using a connection string:
Data Source=CHRIS-LAPTOP\SQLEXPRESS,1433;Persist Security Info=False;User ID=sa;Password=mypasswordhere;
But i get this error:
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: TCP PROVIDER, ERROR: 0 - NO CONNECTION COULD BE MADE BECAUSE THE TARGET MACHINE ACTIVELY REFUSED IT.)
Can anyone help please? with a basic connection string to get me going. The code I have in vb.net I know works as I can connect to a sql server online (azure) no problem.
the connection string for the online sql server (which works) is:
Server=tcp:myservername,1433;Initial Catalog=mydatabase;Persist Security Info=False;User ID=myloginname;Password=mypassword
Many Thanks for your help
Chris
Hello Chris,
use either the instance name or the IP port, but not both. And in .NET you have to quote a backslash =>
Data Source="CHRIS-LAPTOP\\SQLEXPRESS;Persist Security Info=False;User ID=sa;Password=mypasswordhere"
Olaf
- olafhelperBronze Contributor
Hello Chris,
use either the instance name or the IP port, but not both. And in .NET you have to quote a backslash =>
Data Source="CHRIS-LAPTOP\\SQLEXPRESS;Persist Security Info=False;User ID=sa;Password=mypasswordhere"
Olaf