samsmithnz Posted October 28, 2003 Posted October 28, 2003 I'm in the testing phase of a ASP.NET app I've been throwing together over the last week, and I'm having trouble restoring the SQL database, because it keeps saying the database is in use. Theres definetly nothing open referencing it... except for maybe my browser here... and that got me thinking... is calling the close method enough to disconnect from the database? Or should I call dispose too... I understood that I didn't need to call the dispose unless I really needed too... but maybe this will solve my problem??? thanks Sam Quote Thanks Sam http://www.samsmith.co.nz
bungpeng Posted October 29, 2003 Posted October 29, 2003 I don't think there is your application problem. To restore SQL database, normally this message will display (database in use), because someone or we may just use it, so I will restart the SQL service. For your information, if you use dataReader in your application, after finished your job, you need to close it (dataReader.Close) and set it to nothing (dataReader = Nothing) because dataReader will always keep the database connection. And it will cause the error if you try to open database connection again. Quote
samsmithnz Posted October 29, 2003 Author Posted October 29, 2003 But closing the connection should automatically close the datareader too right? Quote Thanks Sam http://www.samsmith.co.nz
bungpeng Posted October 29, 2003 Posted October 29, 2003 Logically it should work right? but I think I need to test on it.... Quote
samsmithnz Posted October 29, 2003 Author Posted October 29, 2003 I was already closing my datareaders and connections when I was finished with them, but I was basically just checking that there was nothing else that I was missing in ASP.NET. I think I like the idea or starting and restarting the server again, except that there are another 4 or 5 developers using the server (but other dadtabases) for their own testing... Quote Thanks Sam http://www.samsmith.co.nz
Administrators PlausiblyDamp Posted October 29, 2003 Administrators Posted October 29, 2003 When you are restoring the database does Enterprise manager have any part of the Database open? Also if you are restoring from Query Analyzer - are you in the database itself? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
samsmithnz Posted October 29, 2003 Author Posted October 29, 2003 I've tryed both methods, and neither helps. I understand enough about query analyser to relieze that I shouldn't have a window oopen. The funny thing is that it returns the dataqabase in use message, so I close all the IE windows and it works... Quote Thanks Sam http://www.samsmith.co.nz
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.