'SQL Connection: Cannot open server "example.com" requested by the login. The login failed
I am attempting to establish a connection to SQL Server with this connection string:
new SqlConnection("Server=tcp:myServer.net,1433;Database=myDatabase;
Trusted_Connection=False;Encrypt=True;MultipleActiveResultSets=True;
User [email protected];Password=SomePassword123")
.Open();
But I keep getting this error. It's like it doesn't respect the @ symbol as part of the username. I tried single quotes, double quotes, and two @@ symbols to see if any of that would escape it but still gives this error about the domain name. It's just part of the username.
Class: 20
ClientConnectionId: {b9d66561-5e69-4a01-840d-86eb9b3066f9}
Data: {System.Collections.ListDictionaryInternal}
ErrorCode: -2146232060
Errors: {System.Data.SqlClient.SqlErrorCollection}
HResult: -2146232060
HelpLink: null
InnerException: null
IsTransient: false
LineNumber: 0
Message: "Cannot open server \"example.com\" requested by the login. The login failed."
Number: 40532
Procedure: ""
Server: "tcp:myServer.net,1433"
Source: "Core .Net SqlClient Data Provider"
SqlState: null
StackTrace: " at System.Data.ProviderBase.DbConnectionPool.CheckPoolBlockingPeriod(Exception e)\r\n at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)\r\n at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)\r\n at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)\r\n at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)\r\n at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions u
serOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)\r\n at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)\r\n at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)\r\n at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)\r\n at System.Data.SqlClient.SqlConnection.Open()"
State: 1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
