Friday, November 18, 2005

OleDb - little known performance hit

I have to work with databases other than SQL Server (shocking, yes, I know), so I use the OleDb data objects quite a bit. I came across something in the MSDN that I did not know and I wanted to make sure that everyone knew about it.


Avoid Accessing the OleDbConnection.State
Property

If the connection has been opened, OleDbConnection.State property makes the native OLE DB call IDBProperties.GetProperties to the DATASOURCEINFO property set for the DBPROP_CONNECTIONSTATUS property, which may result in a round trip to the data source. In other words, checking the State property can be expensive. So only check the State property when required. If you need to check this property often, your application may perform better if you listen for the StateChange event for your OleDbConnection. For details on the StateChange event, see Working with Connection Events.





0 Comments:

Post a Comment

<< Home