0

I hope someone can help me. The code shown here connects perfectly well to my remote SQL Server, but when used in an UWP application, it hangs the app and sometimes throws a network connection error, but does not want to connect and retrieve any info from the SQL Server.

Dim str As String = "Data Source=SQLSERVER-ADDRESS;Initial Catalog=master;Persist Security Info=True;User ID=******;Password=******"
Dim conn As New SqlConnection(str)
    
Dim strSQL As String = "SELECT ID, FName, LName FROM Users" '"SELECT ID, FName, Name FROM Users" 
Dim cmd As New SqlCommand(strSQL, conn)

conn.Open()

Dim rdr As SqlDataReader = cmd.ExecuteReader

While rdr.Read()
    Dim str2 As String = "" & rdr(1) & " " & rdr(2)
    user_list_listbox.Items.Add(str2)

End While

conn.Close()
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • https://stackoverflow.com/a/60860880/11683? – GSerg Jan 07 '22 at 07:31
  • I checked and have all the required capabilities selected, but still does not want to connect – Jaco Helm Jan 07 '22 at 07:43
  • 1
    There are so many things that could go wrong that error messages are fairly important to diagnosing problems. Please [Edit](https://stackoverflow.com/posts/70617678/edit) your question to include the full and complete error message - as text, not screen shot(s). – AlwaysLearning Jan 07 '22 at 08:44
  • Ok, so it seems that after removing and adding the System.Data.SqlClient through Nuget again, it started giving a different issue. Now it does not want to connect but gives a SSL Provider, handshake failed error. Any assistance would be highly Here is the error _System.Data.SqlClient.SqlException: 'A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 31 - Encryption(ssl/tls) handshake failed)' Inner Exception EndOfStreamException: End of stream reached_ – Jaco Helm Jan 07 '22 at 12:05
  • 1
    _Initial Catalog=master_ Nope - you should NOT be using this system database for your own tables. – SMor Jan 07 '22 at 12:13
  • Regardless, I am still having the connection issue. No matter which database I am trying to connect to. – Jaco Helm Jan 07 '22 at 12:14
  • Does this answer your question? [A connection was successfully established with the server, but then an error occurred during the pre-login handshake](https://stackoverflow.com/questions/3270199/a-connection-was-successfully-established-with-the-server-but-then-an-error-occ) – Alex Jan 07 '22 at 13:23

0 Answers0