I'm trying to build my 1st WinForm app which uses SqlExpress and when I click Debug and test my app everything is fine (though occasionally I do get time out errors - but that's another question I guess), however I can't then debug the app again because I get the following error:
"The log scan number (34:410:82) passed to log scan in database '3D1D0C232D2C55B0EF6C455470CD3D4C_S\\VISUAL STUDIO 2005\\PROJECTS\\MYFIRSTAPP\\MYFIRSTAPP\\BIN\\DEBUG\\OTJDB.MDF' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during startup. \r\nAn error occurred during recovery, preventing the database '3D1D0C232D2C55B0EF6C455470CD3D4C_S\\VISUAL STUDIO 2005\\PROJECTS\\MYFIRSTAPP\\MYFIRSTAPP\\BIN\\DEBUG\\OTJDB.MDF' (database ID 5) from restarting. Diagnose the recovery errors and fix them, or restore from a known good backup. If errors are not corrected or expected, contact Technical Support.\r\nCannot open user default database. Login failed.\r\nLogin failed for user 'SQurreL\\Simon'."
I can't delete the ldf or mdb files in the debug\bin folder because they are in use, so I have to stop the SQLExpress service, kill the sqlserv.exe process, delete the ldf and mdb files, then restart the SQLExpress service and try again... which is beginning to get right on my nerves now
Can anyone help with my sanity please?
Hi ganseki,
I think the error message has claimed very clearly: " .....that the log file (.ldf) does not match the data file (.mdf)." If mdf file and the corresponding ldf file cannot match, we cannot open that database again--that's designed by microsoft. So, we need to "If this error occurred during replication, re-create the publication. Otherwise, restore from backup..".
I have to stop the SQLExpress service, kill the sqlserv.exe process, delete the ldf and mdb files, then restart the SQLExpress service and try again
I think what you did is right. So, does this error still occure after you did that? Also i'm curious about what you did to that database thru your application, that you get that error message.
Hope my suggestion helps
|||Thanks for the reply.
Any idea why that is happening each time I debug the app? Or is it normal for WinForms development to have to jump through those hoops in order to test the changes.
It takes longer to stop the service, kill the process, delete the files and restart the service than to make a change to a column width in a datagridview, which if I then find is too narrow or too wide means I have to go through that whole process again just to check that changing the width from 150 to 100 isn't enough? This involves no change to the database, all that would have happened is a select to get the data for the grid, but it happens even without any database interaction - i.e. just opening the app (which starts with a blank page).
After debugging I click the close button on the form, the app closes and Visual Studio quits debug mode. I make changes (which can be as trivial as my illustration above) and then have to go through that routine. And that happens each and every time I want to debug.
It is driving meinsane
Is there something I should be doing differently to stop this from happening?
No comments:
Post a Comment