cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jrahma
Level 6

MDF file location

I am includin g SQL Express 2005 in my setup package and specefying the MDF & LDF files locations in the SQL script but when running the project it still creating both files in the default SQL Server folder in the Program Files!! why?

this is the create part in SQL Script:
[PHP]/****** Object: Database the_internet_cafe Script Date: 03/11/2009 9:12:58 PM ******/
CREATE DATABASE [the_internet_cafe] ON (NAME = N'the_internet_cafe', FILENAME = N'C:\Program Files\Jassim Rahma\TICS\Database\the_internet_cafe.mdf' , SIZE = 3, FILEGROWTH = 1) LOG ON (NAME = N'the_internet_cafe_log', FILENAME = N'C:\Program Files\Jassim Rahma\TICS\Database\the_internet_cafe_log.LDF' , SIZE = 1, FILEGROWTH = 10%)
GO[/PHP]
Labels (1)
0 Kudos
(27) Replies
hidenori
Level 17

Thank you for providing your project. I think that it is a permission issue of your custom database folder. If you change the Script Error Handling setting on the Runtime tab of your script files to "On Error, Abort Installation", I bet you will receive the "CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file '....mdf'. error.

If that is the case, you need to go to Microsoft SQL Server Configuration Manager and click on the Services node from the left pane. From the right pane select the SQL Server service that you target and go to its properties. Change the builtin login from 'Nerwork Service' to 'Local system' and restart the service.

Also, I would suggest that you move the first CREATE TABLE statement through the end of the file to the second script, so that they will run against the the_internet_cafe database, not master.

Hope that helps.
0 Kudos
jrahma
Level 6

hidenori wrote:
If that is the case, you need to go to Microsoft SQL Server Configuration Manager and click on the Services node from the left pane. From the right pane select the SQL Server service that you target and go to its properties. Change the builtin login from 'Nerwork Service' to 'Local system' and restart the service.


but i don't have a specefic server! I am installing the SQL Server Express 2005 included in my setup package so in every setup it will be a fresh installation? any way to grant the required previllages to the script?
0 Kudos
hidenori
Level 17

You can change the logon service account during the Microsoft SQL Server 2005 Express installation. For silent installations, you can specify via the SQLACCOUNT command line parameter. Please check out How to: Install SQL Server 2005 from the Command Prompt for more details.

If you want to assign the Write permission to the folder for the Network Service account, you need to use the new Locked-Down Permission method introduced in InstallShield 2010. Please check out Securing Files, Folders, and Registry Keys in a Locked-Down Environment for more details.

Regards.
0 Kudos
jrahma
Level 6

hidenori wrote:
Also, I would suggest that you move the first CREATE TABLE statement through the end of the file to the second script, so that they will run against the the_internet_cafe database, not master..


Thanks for your help.. I tried it on C:\TEMP and it worked so it's for sure a permission issue. I will check the SQLACCOUNT and let you know

but i didn't understand what do you mean byu the above about the CREATE TABLE..

Do you mean I keep the CREATE DATABASE in the first connection and the rest of the CREATE TABLEs in the second connection? so my frst connection will only have CREATE DATABASE? is that what you are trying to say?
0 Kudos
hidenori
Level 17

jrahma wrote:

but i didn't understand what do you mean byu the above about the CREATE TABLE..

Do you mean I keep the CREATE DATABASE in the first connection and the rest of the CREATE TABLEs in the second connection? so my frst connection will only have CREATE DATABASE? is that what you are trying to say?

Yes, the script under the first connection will run against the master database, and the other script under the second connection will run against the the_internet_cafe database. Therefore, you need to move the line 64 through the end of the file in the first script to the second connection.
0 Kudos
jrahma
Level 6

YAHOOOOO!!!!! 🙂


Finally working properly

can you please explain to me plz what did you do in your 1 to 13 steps so that I know what to do instead of just doing it like an idiot 😄

Thank you sooo much 🙂
0 Kudos
hidenori
Level 17

I am glad that your issue has been solved!

What I suggested was to create two connections; the first one for connecting to the master database to run the script that will create and configure the the_internet_cafe database, and the second one for connecting to the the_internet_cafe database to run the rest of the script that will add items such as tables to the the_internet_cafe database.

Since the the_internet_cafe database does not exist when you click the Next button on the SQLLogin dialog, and both connections use the same login credentials but target a different database, I added a control event so that only the first connection will be validated by the action.

Regards.
0 Kudos