Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Datenbanken (https://www.delphipraxis.net/15-datenbanken/)
-   -   Attach/Dittach DB using Delphi (https://www.delphipraxis.net/177894-attach-dittach-db-using-delphi.html)

question 4. Dez 2013 10:51

Datenbank: mssql • Version: 2005 • Zugriff über: win 7

Attach/Dittach DB using Delphi
 
Hi,
I have created a button called "DBAttached" using delphi and i would like to attached a MSSQL DB by clicking on this button. i am using the following query
Code:
CREATE DATABASE [database_name] ON
( FILENAME = 'C:\Program Files....\test.MDF'),
( FILENAME = 'C:\Program Files ....\test_log.LDF')
 FOR ATTACH ;
but when i run the program and click on the button , i get the error "test.MDF" kann nicht geöffnet werden. Betriebssystemfehler 5: "5(Zugriff verweigert)".
if i run the SQL server management studio as a administrator, then i can attached/dittached any DB using SQL server management studio only,
but how i can do the same using delphi as well?

Klaus01 4. Dez 2013 11:20

AW: Attach/Dittach DB using Delphi
 
Hi,

can you put the database to some other folder (progData)?
In Program-files folder you don't have write permissions.

Best regards
Klaus

question 4. Dez 2013 11:28

AW: Attach/Dittach DB using Delphi
 
Hi Klaus,
yes, i have tried from another directory(c:\user\public) as well but it has the same problem

sx2008 4. Dez 2013 20:08

AW: Attach/Dittach DB using Delphi
 
your user account must have the disk admin server role to attach/detach databases.
The security system of the MS SQL server is quite complex and you need some time to understand it.
http://www.mssqlcity.com/articles/adm/sql70roles.htm
The local windows administrator has by default all rights on the SQL server.
If you're in the context of an normal windows user account you don't have the rights to create/delete/backup/attach/detach databases.


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:09 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz