Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 132,683 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,243 people online right now. Registration is fast and FREE... Join Now!




Troubleshooting SQLServer DB "File In Use By Other Process"

 
Reply to this topicStart new topic

Troubleshooting SQLServer DB "File In Use By Other Process"

Pithecanthropus
post 1 Jun, 2008 - 05:17 PM
Post #1


New D.I.C Head

*
Joined: 13 May, 2008
Posts: 9

Can anyone point me in the right direction to troubleshoot "File In Use By Other Process" type errors, when attempting to attach an MDF file to a Visual Studio 2008 project? FTR this is running in the Vista Business OS.

I have a simple db that I have set up in SQLEXPRESS, to manage process dependencies. This isn't intended for production use IRL; it's just a school project. There are just two tables:

1. ProcessDefinition, which defines a recurrent job to be run, including a unique ProcessName and estimated duration, in addition to a few additional columns that don't matter here.

2. ProcessSuccessorDefinition, which defines for each Process zero, one, or many other processes that follow it and are dependent on it. In a C# app, I'll work backwards through the Successor relationship to work out the "depends on" conditions. This table comprises only two columns, ProcessName and ProcessSuccessor name. The two columns together must be unique in this table, but either one by itself can be a duplicate, so I've attempted to set up the relation accordingly. When working through the Relationship wizard in SQL Server Management Studio, I'm designating the columns in ProcessDefinition as the primary key, and the columns in ProcessSuccessorDefinition as the foreign key.

I've actually done this in a production environment, only there I used Java and a JDBC connection to an Oracle database. Being able to automatically calculate a production schedule was a tremendous help, even though I never developed a data entry interface to make task maintenance easier.

So here's the problem.

When I first set up this database, I made a mistake in setting up the tables, so the data format of two columns i was trying to match were not compatible. But I didn't realize this until I tried to add the database, as a datasource, to my VS2008 C# Windows Forms app. Everything went fine until I was done with the wizard, and it was too late to back out--it erred out saying there was a problem with the relationships.

I fixed that.

Back in Visual Studio, I tried to delete and re-add the datasource, but got an error message saying the file was in use.

Eventually, I deleted the app.config, and any other object in the project that referenced that database and connection string, but I still could not put the data source back in, but when I exited and restarted VS2008, and rebuilt the project, I was finally able to do it.

But I still got the relationship error.

So, next, I deleted the database and rebuilt it.

But after repeating the steps above, I cannot re-add it to my project. It errs out with an error message saying the file is in use. It tells me to close the process that is using the file--but how do I do that? How do I find out what process it is?

How can I avoid this problem in the future?


What would be a good way to troubleshoot this? I can go into task manager and list the processes, but I don't know how to recognize the one that I need to kill.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 06:56AM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month