简体   繁体   中英

How do I connect to SQL Server using Remote Desktop

I am trying to connect to a SQL Server Express on a remote PC using a C# application. When I run the application on my local PC to a local server, it works without any issues. When I use Remote Desktop to connect to a client PC, and run the app (I changed the connection string to the local server address), I get an error:

Error 26: error locating server/instance specified**

Could the issue be in my connection string?

I have tried multiple changes to my connection string (see code below) and even tried the whole UDP connection 1433 TCP/IP port change.

SqlConnection sqlcon = new SqlConnection(@"Data Source=1FEPINMA02\SQLEXPRESS; Initial Catalog=Indigo; User Id=IndigoUser; Password=IndigoUser ;User Instance=False;");

//SqlConnection sqlcon = new SqlConnection(@"Data Source=DAVIDBRITS\SQLEXPRESS;Initial Catalog=Indigo;Integrated Security=True "); // <---------- This is commented out because we tried this also.
sqlconstringx = "Data Source=ipaddress;Initial Catalog=MyDatabase; User ID=MyUsername;password=MyPassword;";

please try.

make sure you can ping the server

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM