Sign In  |  Register
 
 DotNetNuke Powered!
DotNetNuke Support Forums

SQL Express 2005 Problem attaching a database

Rate this topic:

Please Register to post a reply.
Another benefit of registration is the ability to subscribe to and recieve notifications of new posts.

AuthorMessages
sonalij
Posts:24



08/01/2007 10:39 AM  

Ok new problem:

Basically I'm trying to take an existing database (that I was sent from someone) and use it to launch the site and modify it. So the portal already exists, if that makes sense. 

I have a database in SQL Express called DNN. This takes its files from the location C:\dnndb.
Then I have my Virtual Directory called DNN. This takes its files from the location C:\Websites\DNN.

I think the big issue I'm having it getting my virtual directory code (ie. web.config) to recognize and use the database. I currently have these two lines:
connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True; AttachDBFilename=C:\dnndb\DNN_Data.mdf;"

But I get this error:

DotNetNuke Upgrade Error

The Assembly Version ( [ASSEMBLYVERSION] ) does not match the Database Version ( [DATABASEVERSION] )

ERROR: Could not connect to database.

Unable to open the physical file "C:\dnndb\DNN_Data.mdf". Operating system error 5: "5(Access is denied.)". An attempt to attach an auto-named database for file C:\dnndb\DNN_Data.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

sonalij
Posts:24



08/01/2007 11:01 AM  
I also tried getting in from the admin account on my computer, and by fiddling with permissions etc I got a different error:

Unable to open the physical file "C:\dnndb\DNN_Data.mdf". Operating system error 32: "32(The process cannot access the file because it is being used by another process.)". An attempt to attach an auto-named database for file C:\DotNetNuke Website1\App_Data\Database.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

John Mitchell
Posts:3040



08/01/2007 11:24 AM  
If you are using SQL Management studio to manage the DB then you can change the connection string from using a "User Instance" to specifying the database directly like in regular SQL Server.

Change this:
Data Source=.\SQLExpress;Integrated Security=True;User Instance=True; AttachDBFilename=C:\dnndb\DNN_Data.mdf;

To this:
Data Source=.\SQLExpress;Integrated Security=True;User Instance=False;Database=DNN;
sonalij
Posts:24



08/01/2007 11:34 AM  
Ok I tried that and got this error again:
Invalid URI: The hostname could not be parsed.

Now I'm currently in my account and undid the changes I'd made to permissions earlier (so I get the error #5, not #32). Should I go back and change permissions and then retry this change you suggested? If so exactly what permissions do I need to set.

Just to explain a bit, in the folder C:\dnndb\ there are two files: DNN_Data.mdf and DNN_Log.lgf

Also a question: in your suggestion you changed AttachDBFilename=C:\dnndb\DNN_Data.mdf to Database=DNN and I'm wondering how it will know where to find this database (since like I'd mentioned earlier the files are in one folder while the database is saved in a different folder).

Thanks for taking the time to help me out!
John Mitchell
Posts:3040



08/01/2007 11:44 AM  

Do you have a control panel for managing your Database and/or account on your host server? 

I used the Database=DNN name because you said in your initial post:
"I have a database in SQL Express called DNN"

Using a database manager you can tell the SQL Express Engine where the DB files are and the connection string will then be able to use the name that you specified in the DB Managment console.

sonalij
Posts:24



08/01/2007 11:53 AM  
Ok I'm sorry I'm super new to all of this and still trying to figure it all out.

Where would I find a database manager/control panel?

If I go into the SQL Express and right click on the database DNN I can get into Properties, where I've checked that the file paths are correct for the .mdf and .lgf files. I did notice that the "Logical Names" are DotNetNuke2_Data and DotNetNuke2_Log (but the database is still called DNN and the correct files are specified). Also the two users who are set as owners only have one permission - connect. Do they need more? Should I have userid in my connectionString (I currently don't).

And should I change any permissions in the folder C:\dnndb?
John Mitchell
Posts:3040



08/01/2007 3:48 PM  

Hi, I think when you say that you "go into SQL Express and right-click on the database" that you are actually using the database management program I am talking about. It looks like this:

If you have a named user then it would be good to use that user in your connection string so that you do not have to get permisions for the website to be trusted in the Database.

The User should be given DBO privledges.

There is a pretty good Step by Step setup here:
http://www.dotnetnuke.com/Community/ForumsDotNetNuke/tabid/795/forumid/107/threadid/38723/scope/posts/Default.aspx

 

packrat
Posts:64



10/10/2007 4:03 PM  

Hi John,

Came across this post and realized it was one of the few post I had seen where someone with an extensive knowledge of dnn had address some basic SQL Express questions and in particular, questions concerning the management tool SQL Managment Studio Express.  I'm sure there are many folks who originally set up their sites using the free tools provided by MS and encouraged in the DNN documentation.  Many development environments probably look very similar to mine:

Either Windows Server 2003 or XP Pro
Visual Web Developer
SQL Express 2005
IIS6

Now to the questions and how they relate to this post. I too frequently receive the previously posted error when trying to connect to my db via the database management tool.  It happens when I'm trying to attach the db to do a backup or restore operation. I n order to get past the error, I have to do things like kill the worker process associated with either the ASPNET Machine account or Network Service account, depending on  what operating system I'm working on at the time.  I searched and posted for help on the appropriate forums for these tools but receive no help.

I did not intially create an empty db with this tool when I first installed dnn.  I also did not have to make any changes to the connection strings in the web.config file and my installation went smoothly.  So, I have a db just named database with no username/password info in the connection string.  I assume that I can sometimes connect to the db using the management tool only because I set the program up to use windows authentication and not SA.  I also assume that VWD connects the same way, through or by windows authentication.

I tried to implement your suggestion posted earlier so as to rid myself of this frequent error I receive when trying to attach the db through the management tool but when I change the entry(s)? in my web.config, the site would not load.  It wouldn't be such a big deal to have to do  things like kill the wp.exe to attach the db if I only did it frequently, but the more I try to customize/personalize my dnn installation I am more and more having to interact with the db.  So this error is a real irritant.  Her's what I've done so far:

Original connection strings:

Modified connection strings in order to change the way SQL sees the db:

Once done, I get the following error:

Cannot open database "Database.mdf" requested by the login. The login failed. Login failed for user 'ADM-LTDEVELOP\ASPNET'.

What did I do wrong?  This is my dev site so it's not urgent.  I'm just trying to improve my effeciency with working with dnn and getting rid of this problem would help me with my backup and restore procedures.

Long winded I know:-) but I try to be precise in my explanations.

Thanks,

Paul

 

John Mitchell
Posts:3040



10/12/2007 8:16 AM  

If you connect to the DB with a named user and attach it in SQL Express manager you should have smoother sailing.

There is a blog about the trouble you are having here:

http://www.dotnetnuke.com/Community/Blogs/tabid/825/EntryID/1202/Default.aspx

You may still have to kill the asp.net process to detatch or backup the DB, but that happens with any DB that has a connection from ASP.Net, even in SQL Server.

packrat
Posts:64



10/12/2007 1:52 PM  

Thanks John...always the resourceful one.  The blog helped me a great deal.

Paul

Please Register to post a reply.
Another benefit of registration is the ability to subscribe to and recieve notifications of new posts.

Forums >DotNetNuke Support >General-DNN-Help > SQL Express 2005 Problem attaching a database



ActiveForums 3.7
Visit our Store for great DotNetNuke Modules and Skins
DNNMasters Sitemap/Google Sitemap 3.0

Item codeSM3-01
Price$29.00
Product Information 
DotNetNuke CSS NavMenu 3.3 (Developers)

Item codeCSSNM33DEV
Base Price$149.00
Product Information 
Snapsis PageBlaster 3.3.2 for DotNetNuke - Professional Edition

AuthorJohn Mitchell
Base Price$79.00
Product Information