I am trying to create the application in this demo but with my own database. All I am trying to do for now, is show one data table. I am using Visual studio 2017 pro, and am connecting to an older SQL Server version 10.50.1600. I am able to connect to the database with windows authentication via SSMS, but when I try to connect with my application I get the following error message.
A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 0 - The operation completed successfully)
I have spent hours looking around the internet for a solution for this error. There seem to be many reasons that this error can come up but I have yet to see a solution that worked for me.
I'm wondering if people can give me tips on where I can look to see why this is happening. I can't see anything helpful in the Autos list, but I'll attach it in case there's something that jumps out at others.
My connection string and class are below. As I mentioned, it does connect, but then complains about something at login:
Screenshot of error message
Connection String
public string ConnectionString { get; set; } = "Server=servername; Trusted_Connection=Yes; Integrated Security=True;";
Connection Class
public ObservableCollection<MyAssignments> GetMyAssignments(string connectionString)
{
string GetMyAssignmentsSQLFile = File.ReadAllText(@".\SQL\MyOpenAssignments.sql");
var myAssignments = new ObservableCollection<MyAssignments>();
try
{
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
if (conn.State == System.Data.ConnectionState.Open)
{
using (SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandText = GetMyAssignmentsSQLFile;
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
var myAssignment = new MyAssignments();
myAssignment.CallID = reader.GetString(0);
myAssignment.RecvdDate = reader.GetString(1);
myAssignment.CallStatus = reader.GetString(2);
myAssignment.Priority = reader.GetString(3);
myAssignment.Classification = reader.GetString(4);
myAssignment.CallDesc = reader.GetString(5);
myAssignment.CloseDesc = reader.GetString(6);
myAssignments.Add(myAssignment);
}
}
}
}
}
return myAssignments;
}
catch (Exception eSql)
{
Debug.WriteLine("SQL-Exception: " + eSql.Message);
}
return null;
}
}
SQL Server error 233 occurs because the SQL Server client cannot connect to the server and is not configured to accept remote connections. To fix this issue, except for enabling Shared Memory and TCP/IP, we still need to activate Named Pipe protocols with SQL Server Configuration Manager tool.
Right-click on your connection and select "Properties". You will get the Properties window for your connection. Find the "Connection String" property and select the "connection string". So now your connection string is in your hands; you can use it anywhere you want.
means that the client application was able to complete the TCP 3-way handshake properly (hence you notice “ A connection was successfully established with the server ”), but during the pre-login handshake, the client application checks with the SQL Server on the TDS protocol version to be used henceforth for the ...
Try using SQL Server Authentication instead of Windows Authentication, what means setting Integrated Security=False; and including user & password among other parameters in your connection string.
ConnectionString="Server=tcp:devsqlserverXXXX.database.windows.net,1433;Initial Catalog=XXXX;Persist Security Info=False;User ID=USER_ID_XXXX;Password=pa$$wordXXXX; MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=90;";
Could it be that your user has access to the database server but not the database?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With