0

I receive an exception anytime I put a value in for uid= in connection string for an Odbc PostgreSQL connection using Windows Authentication (SSPI).

Error:

Connection problem: System.InvalidOperationException: The connection was not closed. The connection's current state is connecting.
   at System.Data.ProviderBase.DbConnectionClosedConnecting.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.Odbc.OdbcConnection.Open()
   at ConsoleApplication1.Program.TestMethod(String connectionMethod)

Code (first call of Open() in the program because pulled to code out for testing) :

try
         {
            using (OdbcConnection connection = new OdbcConnection(odbc_connection_string))
            {
               connection.Open();
            }
         }
         catch (Exception ex)
         {
            System.Diagnostics.Trace.WriteLine("Connection problem: " + ex);
            odbc = false;
         }

Connection strings:

odbc_connection_string = "uid=bwhuggin@CCANET;Driver={PostgreSQL Unicode};database=hostdb-4.2.0;server=localhost;port=5432;Trusted_Connection=yes";

Npgsql connection allows for the input username:

npgsql_connection_string = "Server=localhost;Port=5432;Database=hostdb-4.2.0;User Id=bwhuggin@CCANET;Integrated Security=true;";
T-Heron
  • 5,385
  • 7
  • 26
  • 52
Branden Huggins
  • 695
  • 7
  • 8

1 Answers1

0

I'm not sure why I showed InvalidOperationException errors. Normally I was getting AccessViolationExceptions.

One of the psqlodbc 9.3 drivers was the source of this problem. I changed the psqlodbc driver to 9.5.4 and I was able to input a value in the uid field.

Branden Huggins
  • 695
  • 7
  • 8