Hi
Running SQL Express 2008, creating a linked server to a Access 97 DB.
Execute the following SQL:
WHILE 1 = 1 BEGIN IF EXISTS (SELECT 1 FROM [master].[dbo].[sysservers] WHERE srvname = 'MyLinkedServer') BEGIN EXECUTE "sp_dropserver" MyLinkedServer, "droplogins" END BEGIN EXECUTE sp_addlinkedserver 'MyLinkedServer', 'OLE DB Provider for Jet', 'Microsoft.Jet.OLEDB.4.0', 'C:\Test.mdb' SELECT MyField FROM MyLinkedServer...MyTable WHERE MyField = 'XXX' END END
Runs perfect n times. And then, every nth time it will error with:
OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "MyLinkedServer" returned message "Cannot open database ''. It may not be a database that your application recognizes, or the file may be corrupt.".
Msg 7303, Level 16, State 1, Line 11
Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "MyLinkedServer".
I'm actually trying to debug this issue for a .net program which throws the same error except it actually stops SQL Express creating a linked server until the service is restarted or the PC is rebooted. I've taken .net out of the equation to try and nail issue and what is causing it.
If I then execute the above SQL again after the error it works perfectly, until the next time.
Anyone have any ideas what is going on here?