cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
kclawes
Level 3

Cannot Create new DB in folder IS is installing?

During install I am running a SQL script to create a database. I want to have the database reside in a folder that IS will install on the user's machine.

So for instance, I want it to install at \DB

When IS runs the SQL script, I get the following error.

Error 27506.Error executing SQL script sqlscript.sql. Line 49. CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file 'c:\path\to\dir\data.mdf'.(5123)


I'm assuming that until IS is done running, any folders it creates are read-only. As such, I can't create the DB where I want.

Does anyone know a work around for this?

I should also note, that if I tell my script to create the DB in a DIR that IS is not creating, it works fine.

Thanks in advance
Labels (1)
0 Kudos
(6) Replies
hidenori
Level 17

How do you create the desired folder using IS?
0 Kudos
kclawes
Level 3

I've added the folders in "Files and folders" as seen in this image

http://sparq-l.com/stuff/images/oops/folders.jpg

Is there an alternate method I should be using?
0 Kudos
hidenori
Level 17

Do you correctly specifiy the path of a database file that you attempt to create in your SQL script? I am assuming that you want to create it under C:\Program Files\Leo Software\Leo\DB folder, but the error message is stating 'c:\path\to\dir\data.mdf'.
0 Kudos
kclawes
Level 3

Yeah, I am using the correct path. Sorry for the confusion. In the error message, I was just trying to make it more legible.

But my SQL script does in fact point to C:\Program Files\Leo Software\Leo\DB
0 Kudos
hidenori
Level 17

It seems an issue or limitation of Microsoft SQL Server 2005 Express Edition. The behaivor is reproduced (even if you run the same script from Microsoft SQL Server Management Studio) when you specify any path containing one or more space characters for a database file in the CREATE DATABASE statement. It is working with Enterprise Edition. One workaround I can think of is to copy your database file to the target machine and call sp_attach_db stored procedure in order to create the database.
0 Kudos
kclawes
Level 3

Well, it's not the answer I was hoping for, but at least I know it isn't from me doing something incorrectly.

Thanks for the alternate suggestion, I might give that a try.
0 Kudos