0

I have been trying to fix a project which already use a 100% connections to Oracle. They are trying to upgrade the project to start using SQL Server 2012 Management Studio. But I'm having issues connecting to the database. We use Windows authentication.

I can login fine directly to SQL Server 2012 using Management Studio and Windows authentication. If I create a fresh new WindowsApplication1 project to test the connection code it works fine, I'm using this code (and get an error is at conn.Open()):

Imports System.Data.SqlClient

Public Class Open_Filing_Image
    'Create ADO.NET objects.
    Private myConn As SqlConnection
    Private myCmd As SqlCommand
    Private myReader As SqlDataReader
    Private results As String

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    'Create a Connection object.
    Dim connStr As [String] = "Server=servername; Database=dbname; Integrated Security=True"
    myConn = New SqlConnection(connStr)
    'Create a Command object.
    myCmd = myConn.CreateCommand
    myCmd.CommandText = "SELECT DdocName FROM dbo.Document WHERE XAlaskaID = '72010' and DdocType = 'Filings'"
    'Open the connection.
    Try
        myConn.Open()
        MsgBox("Connection Open ! ")
    Catch ex As Exception
        MsgBox("Can not open connection ! ")
    End Try
    myReader = myCmd.ExecuteReader()

    'Concatenate the query result into a string.
    Do While myReader.Read()
        results = myReader.GetValue(0)
    Loop
    'Display results.
    Dim documentID As String = results
    Dim outPath As String = "http://address.internet`enter code here`/" + documentID + (".pdf")
    System.Diagnostics.Process.Start(outPath)
    'Close the reader and the database connection.
    myReader.Close()
    myConn.Close()
End Sub
End Class

Error message:

A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The specified data could not be decrypted.

Thank you.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Joel Jacobson
  • 145
  • 3
  • 15
  • Your problem-statement is contradictory. You said "If I create a fresh new WindowsApplication1 Project to test the connection code it works fine" but then describe an error message. – Dai Jan 13 '17 at 20:11
  • Also the same issue is reported elsewhere with several possible causes and solutions, are you certain none of these apply? http://stackoverflow.com/questions/34430550/a-connection-was-successfully-established-with-the-server-but-then-an-error-occ – Dai Jan 13 '17 at 20:12
  • Yes, I test my conde with any VS 2010, 2013 and 2015 and works the connection, I can pull sqlcommand and sqlreader fine. But im working on a project that already was build by old programmers written in vb.net 2010 and all connections is based on oracle. im just trying to make a simple connection to test, but that is the message I get. – Joel Jacobson Jan 13 '17 at 20:14
  • Please post your connection code from the project that doesn't work. Your `Form1` code is not relevant here. – Dai Jan 13 '17 at 20:15
  • I edit my original post, sorry first time in here. Also I check your link and nothing of that worked for me. – Joel Jacobson Jan 13 '17 at 20:32
  • Try adding "Encrypt=yes;" to your connection string. If that doesn't work, try switching it to "no". – RBarryYoung Jan 13 '17 at 20:40
  • when using Encrypt=yes in my connection string I get: A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.) If I use Encrypt=No I get: A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The specified data could not be decrypted. ) – Joel Jacobson Jan 13 '17 at 20:55
  • You are missing the Provider. Add this to your connection string (assumes SQL Server 2012): `Provider=SQLNCLI11;` – Laughing Vergil Jan 13 '17 at 21:09
  • I tried using that `Provider=SQLNCLI11` and it says provider not supported. – Joel Jacobson Jan 13 '17 at 22:38

1 Answers1

0

Fix it doing some research and some assistance by another programmer:

The project had a Bcrypt reference that block the connections to SQL. I delete all Bcrypt and add transport credentials to Windows in the app.config. any way thanks guys.

Joel Jacobson
  • 145
  • 3
  • 15
  • Use the edit link in your question. Don't post anything as an answer, unless it is the answer to your question. – James Z Jan 13 '17 at 20:26