Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing Application Name on SQL Server Connection

Can the Application Name passed to SQL Server (via the ADO Connection string) be changed once the connection is open without closing and re-opening the connection?

In particular, I'm using ADO, not ADO.NET, and the SQLOLEDB.1 OLE DB Provider.

We embed the session information in the Application Name, to help us identify the connection specific to a user's session. This primarily helps when troubleshooting bad queries or performance issues.

We currently do not use a connection pool for our ADO connections. I'm considering implementing a connection pool, but would like to update the Application Name when a connection is removed from the pool, so that we have accurate session information in the Application Name.

like image 263
Jon Robertson Avatar asked Oct 29 '25 00:10

Jon Robertson


1 Answers

I suggest to use SQL CONTEXT_INFO, 128 bytes available per connection, which can be changed at runtime: http://msdn.microsoft.com/en-us/library/ms189252%28v=sql.105%29.aspx

like image 100
Robert Niestroj Avatar answered Oct 31 '25 17:10

Robert Niestroj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!