SQL Express refusing to reconnect to database following access from Visual basic
-
lundi 5 mars 2012 20:49
Hi All,
My database is giving the scare. Each time I connect to it from Visual Studio, SQL Express reports that the database file is corrupt. To get it working again, I would copy the database file, delete the existing file, paste the copy from the clipboard and reattach it to the database engine. I am a beginner in both SQL and VB and I have no idea whether the problem is in my SQL installation or in VB. Does anyone out there understand what is happening?
Thanks for your responses.
Toutes les réponses
-
mercredi 7 mars 2012 02:52Modérateur
SQL Express reports that the database file is corrupt.
Hi uwa,
You could use DBCC CHECKDB (T-SQL) to check the logical and physical integrity of all the objects in the specified database.
Reference:
DBCC CHECKDB: http://msdn.microsoft.com/en-us/library/ms176064.aspx.
Thanks,
Maggie
Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.
-
mercredi 7 mars 2012 06:21
Thanks. I issued the DBCC on the database and got the following result:
"CHECKDB found 0 allocation errors and 0 consistency errors in database 'E:\SQL DATABASES\....
DBCC execution completed. If DBCC printed error messages, contact your system administrator".
I supose that shows there are no errors. May be the problem is in my VB codes?
-
mercredi 7 mars 2012 08:49
Hello again.
I have tried to connect to Northwind database from my VB application. The connection was successful and I could insert or delete rows from a table. However, when I attempt to directly open a table in the the database from the SQL server, I get the error message show in the image.
When I close the VB program and try to run DBCC CHECKDB on the database, I get the following error message:
"Msg 945, Level 14, State 2, Line 3
Database 'E:\SQL DATABASES\NORTHWIND.MDF' cannot be opened due to inaccessible files or insufficient memory or disk space.
See the SQL Server errorlog for details".I know for sure that there is sufficient disk space. I also know that Line 3 that is now causing the error did not cause error until I connected to the database from VB. Some of the log files show the following error messages:
"Date 07-Mar-12 8:43:35 AM
Log SQL Server (Current - 07-Mar-12 9:27:00 AM)Source spid51
Message
Error: 17204, Severity: 16, State: 1."*********************************************
"Date 07-Mar-12 8:43:35 AM
Log SQL Server (Current - 07-Mar-12 9:27:00 AM)Source spid51
Message
FCB::Open failed: Could not open file E:\SQL Databases\Northwind.mdf for file number 1. OS error: 32(The process cannot access the file because it is being used by another process.)."*******************************************
"Date 07-Mar-12 8:43:36 AM
Log SQL Server (Current - 07-Mar-12 9:27:00 AM)Source spid51
Message
Error: 17204, Severity: 16, State: 1."
*******************************************
"Date 07-Mar-12 8:43:36 AM
Log SQL Server (Current - 07-Mar-12 9:27:00 AM)Source spid51
Message
Error: 5105, Severity: 16, State: 1."********************************************
Who can help me out? I may well be heading for trouble with somebody if I cannot resolve this issue and deliver my task.

