I have a Windows DLL that writes to a SQL Server database to log application data on average every minutes or so. It runs fine apart from two or three times a day the following error occurs:

COM Error object:
Code = 0x80004005
Description = Cannot open database requested in login ''. Login fails.
Help Context = 0
Help File = (null)
Source = Microsoft OLE DB Provider for SQL Server
ADO Error object:
Description = Cannot open database requested in login ''. Login fails.
Help Context = 0
Help File = (null)
Native Error = 4060
Number = 0x80004005
Source = Microsoft OLE DB Provider for SQL Server
SQLState = 21285640

After the error, the db operation that required the connection is abandoned. Subsequent calls to the dll then work fine and continues normally writing to the database with no problems until the next error.

I am opening a database connection using the following connection string:

Provider=sqloledb;Data Source=OLDA;Initial Catalog=(local);Integrated Security=SSPI

When loaded into a hex editor the database name in the error message above (in the single quotes) contains a single ASCII 0x01 (SOH)!

Does anyone have any ideas what is going on?

Any help much appreciated.