I have written a C# ASP.NET application that uses the Windows TD ODBC driver (v 13.10.00.10). In my code, I create an open a connection, perform my query, then close the connection. However, what we are seeing is that the connection (session) persists in Teradata for some arbitrary amount of time after the application has finished with the connection and closed it. My code is below.
I'm trying to understand what happens on the Terdata side once an application closes a connection via ODBC. Is there any way to explicitly end the session as soon as the application is done using it with ODBC?
Some of the connections disappear from DBC.SESSIONINFO in a matter of 10 seconds, some take 10-15 minutes before they finally disappear.
Any help would be most appreciated.
private void current_Way() { OdbcConnection conn = null; try { String q = "SEL sessionno, username FROM DBC.SESSIONINFO WHERE USERNAME = 'my_user';"; Response.Write(q + "<br/>"); conn = new OdbcConnection("DSN=mydsn"); conn.Open(); OdbcCommand cmd = new OdbcCommand(q, conn); OdbcDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { Response.Write(dr[0].ToString() + "" + dr[1].ToString() + "<br/>"); } dr.Close(); conn.Close(); conn.Dispose(); Response.Write("Connection state? " + conn.State + "<br/>"); Response.Write("DataReader closed? " + dr.IsClosed); }//end try catch (Exception ex) { Response.Write(ex.Message); } finally { } }