RE: How to get permission to backup DB to \My Documents\ folder

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I'm using VB 2005 with SQL Server 2005. I log onto Windows as the
administrator. I'm not sure/familiar about SQL Server, although since I am
the only one using this PC, I assume I am logged on as sysadmin.

If I use the SQL Server Mgt Studio to back up to My Docs folder, it works.
It's only when I do it programmatically as below do I get the exception.

I use a SqlCommand along with the ExecuteNonQuery command to backup my
database. When I back up the DB to a file in the Program Files/Microsoft SQL
Server/ folder, as shown below

Dim backupSQL As New SqlCommand("BACKUP DATABASE [Companies DB] TO
DISK='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\Companies
DB.bak' WITH CHECKSUM")

, it works,
but when I try to back up to a file in the My Documents folder, as shown
below,

Dim backupSQL As New SqlCommand("BACKUP DATABASE [Companies DB] TO
DISK='C:\Documents and Settings\Ed\My Documents\Companies DB.bak' WITH
CHECKSUM")

it throws an exception:

SqlException was unhandled
Cannot open backup device 'C:\Documents and Settings\Ed\My
Documents\Companies DB.bak'. Operating system error 5(Access is denied.).
BACKUP DATABASE is terminating abnormally.
--
Ed


"Charles Wang[MSFT]" wrote:

Hi Ed,
To let me better understand your issue, I would like to know:
1. How do you back up your database, programmatically or manually?
2. Was your Windows logon account a local administrator?
3. Was your SQL Server logon account a sysadmin?
4. What was the exact error message?

For checking if this issue is a permission issue, you can logon your
Windows with administrator account, assign the folder Read/Write
permissions to your current Windows logon account. Right click the My
Document folder which locates in C:\Documents and Settings\<your Windows
logon account>\My Documents by default, click Properties, switch to the
Security tab, click Add..., enter your Windows account name, assign Read
and Write permissions, and click OK. Try again.

If you have any other questions or concerns, please feel free to let me
know.

Charles Wang
Microsoft Online Community Support




.



Relevant Pages

  • Re: Saving WSS site prior to upgrading SQL Server 2005 Express to Standard/Enterprise
    ... Your backup is from a different version of Windows SharePoint Services and ... SQL Server 2005 is available. ... The advantages of the embedded version ("Windows Internal Database") over ...
    (microsoft.public.sharepoint.windowsservices)
  • IIS / SQL Server impersonation
    ... I am attempting to implement impersonation from a windows application ... I have configured the host virtual directory in IIS to require windows ... the database permits Windows Authentication. ... When I try and open a connection to SQL Server: ...
    (microsoft.public.dotnet.security)
  • Re: trouble moving db to 2005 from 2000
    ... using windows authentication and logged in under my windows account) in ... The error "The proposed new database owner is already a user or aliased in ... create user rudolf ... You are only "sa" within SQL Server. ...
    (microsoft.public.sqlserver.programming)
  • Re: Cannot link to SQL server
    ... When I click on the database file, ... Windows needs to know the program you want to use to open it. ... Opening SQL Server Management Studio ... I then get another dialog 'Create a New Data Source to SQL ...
    (microsoft.public.access.externaldata)
  • Re: User setup problem.
    ... login permissions for SQL Server. ... have access to SQL Server and the database through their ... windows group role membership which has the permissions.. ...
    (microsoft.public.sqlserver.security)