943,590 Members | Top Members by Rank

Ad:
  • MS SQL Discussion Thread
  • Unsolved
  • Views: 2185
  • MS SQL RSS
Sep 11th, 2009
0

MS SQL Permission on IIS 6

Expand Post »
Hello everyone,

i wrote an application that makes database backups and zips them.

Can anyone please tell me what i need to do in order to get the apllication to work on IIS 6 windows server 2003 SQL 05

1. The application works fine on machines for both XP and VISTA.
2. The application runs fine on Win Server 2003 however :

my problem is : obviously the database is in use by the web site.

How can i give my application permission to make the backup while the website is connected to the database ?

regards,
Similar Threads
cVz
Reputation Points: 29
Solved Threads: 7
Junior Poster
cVz is offline Offline
139 posts
since Mar 2008
Sep 11th, 2009
0

Re: MS SQL Permission on IIS 6

You need to issue a backup command to the SQL Server and then archive the .bak file. You never want to access the .mdf and .ldf files directly.

Use this query:
BACKUP DATABASE [DBName] TO  DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL\BackUpManual\DBName.bak' WITH  INIT ,  NOUNLOAD ,  NAME = N'DBName backup',  NOSKIP ,  STATS = 10,  NOFORMAT

Note: The file path is relative to the machine running the SQL Server, not the client issuing the command
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Sep 11th, 2009
0

Re: MS SQL Permission on IIS 6

Hi my friend , i have that .

SQL Syntax (Toggle Plain Text)
  1. /// <summary>
  2. /// Backups are done here
  3. /// </summary>
  4. #region Backup Methods
  5. #region Full Backup method
  6. void Fullbackup()
  7. {
  8.  
  9. method = "Full";
  10. // Creating connection
  11. Username = txtUsername.TEXT;
  12. Password = txtPassword.TEXT;
  13. // specifying connection string
  14. DBhandler.DbWinHandler dbHandler = new DBhandler.DbWinHandler("Data Source=" + txtServerName.TEXT + ";Initial Catalog=master;Persist Security Info=True;User ID=" + Username + ";Password=" + Password);
  15.  
  16. // Getting the items that has to be backed up
  17. foreach (string lstItem IN listBoxControl2.Items)
  18. {
  19. dbName = lstItem;
  20.  
  21. if (!Directory.EXISTS(textEdit1.TEXT + "/DataSafe Backups/Temp/"))
  22. {
  23. DirectoryInfo newDir = new DirectoryInfo(textEdit1.TEXT + "/DataSafe Backups/Temp/");
  24. newDir.CREATE();
  25. }
  26.  
  27. lblStatus.TEXT = "Backing up " + dbName;
  28. lblStatus.Refresh();
  29. dbHandler.SmartGetDataSet("BACKUP DATABASE " + dbName + " TO DISK = '" + textEdit1.TEXT + "/DataSafe Backups/Temp/" + dbName + ".bak' WITH NAME = '" + dbName + ".bak'");
  30.  
  31. ZipFile();
  32. }
  33. }
  34. #endregion
  35.  
  36. #region Differential Backup method
  37. void Diffbackup()
  38. {
  39. method = "Diff";
  40. // Creating connection
  41. Username = txtUsername.TEXT;
  42. Password = txtPassword.TEXT;
  43. // specifying connection string
  44. DBhandler.DbWinHandler dbHandler = new DBhandler.DbWinHandler("Data Source=" + txtServerName.TEXT + ";Initial Catalog=master;Persist Security Info=True;User ID=" + Username + ";Password=" + Password);
  45.  
  46. // Getting the items that has to be backed up
  47. foreach (string lstItem IN listBoxControl2.Items)
  48. {
  49. dbName = lstItem;
  50.  
  51. if (!Directory.EXISTS(textEdit1.TEXT + "/DataSafe Backups/Temp/"))
  52. {
  53. DirectoryInfo newDir = new DirectoryInfo(textEdit1.TEXT + "/DataSafe Backups/Temp/");
  54. newDir.CREATE();
  55. }
  56.  
  57. lblStatus.TEXT = "Backing up " + dbName;
  58. lblStatus.Refresh();
  59. dbHandler.SmartGetDataSet("BACKUP DATABASE " + dbName + " TO DISK = '" + textEdit1.TEXT + "/DataSafe Backups/Temp/" + dbName + "_Differential.bak' WITH DIFFERENTIAL, NAME = '" + dbName + ".bak'");
  60.  
  61. ZipFile();
  62. }
  63. }
  64. #endregion
  65.  
  66. #region LOG backup method
  67. void Logbackup()
  68. {
  69. method = "Log";
  70. // Creating connection
  71. Username = txtUsername.TEXT;
  72. Password = txtPassword.TEXT;
  73. // specifying connection string
  74. DBhandler.DbWinHandler dbHandler = new DBhandler.DbWinHandler("Data Source=" + txtServerName.TEXT + ";Initial Catalog=master;Persist Security Info=True;User ID=" + Username + ";Password=" + Password);
  75.  
  76. // Getting the items that has to be backed up
  77. foreach (string lstItem IN listBoxControl2.Items)
  78. {
  79. dbName = lstItem;
  80.  
  81. if (!Directory.EXISTS(textEdit1.TEXT + "/DataSafe Backups/Temp/"))
  82. {
  83. DirectoryInfo newDir = new DirectoryInfo(textEdit1.TEXT + "/DataSafe Backups/Temp/");
  84. newDir.CREATE();
  85. }
  86.  
  87. lblStatus.TEXT = "Backing up " + dbName;
  88. lblStatus.Refresh();
  89. dbHandler.ExecuteCommand("BACKUP LOG " + dbName + " TO DISK = '" + textEdit1.TEXT + "/DataSafe Backups/Temp/" + dbName + "_LOG.bak' WITH NAME = '" + dbName + ".bak'");
  90.  
  91. ZipFile();
  92. }
  93. }
  94. #endregion
  95. #endregion

PS the DBhandler.DbWinHandler is just a class we use to connect to SQL.

should i add any of the following ?

INIT ,
NOUNLOAD
NOSKIP ,
STATS = 10,
NOFORMAT

????
Last edited by cVz; Sep 11th, 2009 at 7:40 am.
cVz
Reputation Points: 29
Solved Threads: 7
Junior Poster
cVz is offline Offline
139 posts
since Mar 2008
Sep 11th, 2009
0

Re: MS SQL Permission on IIS 6

What is the error you receive?
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Sep 11th, 2009
0

Re: MS SQL Permission on IIS 6

well it just bounces ...

No error...

however the backup file is 0 bytes
cVz
Reputation Points: 29
Solved Threads: 7
Junior Poster
cVz is offline Offline
139 posts
since Mar 2008
Sep 11th, 2009
0

Re: MS SQL Permission on IIS 6

Well try a full backup (using the query I posted) instead of a differential backup. This will indicate if backups are working at all.
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MS SQL Forum Timeline: SQL Query Problem
Next Thread in MS SQL Forum Timeline: Simultaneous Data Update - "Record Locking"





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC