数据库备份问题?
各位大哥各大姐,帮帮小弟吧~我没辄了!问题如下:
做一个SQL Server数据库备份问题,在bin中已经引用了Interop.SQLDMO.dll,Interop.ADODB.dll,Interop.ADOX.dll,Interop.JRO.dll这四个文件了,在本地测试是可以备份的,但传到服务器上就提示错误,请问该如何解决,在此谢谢了!
出错代码如下:
[img=http://bbs.bccn.net/attachment.php?aid=37900&k=b2378dc608bbf82c91f90f8d04332861&t=1224315260][/img]
下面是备份的主要代码
public static void SQLBACK(string ServerIP, string LoginName, string LoginPass, string DBName, string BackPath)
{
SQLDMO.Backup oBackup = new SQLDMO.BackupClass();
SQLDMO.SQLServer oSQLServer = new SQLDMO.SQLServerClass();
try
{
oSQLServer.LoginSecure = false;
oSQLServer.Connect(ServerIP, LoginName, LoginPass);
oBackup.Action = SQLDMO.SQLDMO_BACKUP_TYPE.SQLDMOBackup_Database;
oBackup.Database = DBName;
oBackup.Files = BackPath;
oBackup.BackupSetName = DBName;
oBackup.BackupSetDescription = "数据库备份";
oBackup.Initialize = true;
oBackup.SQLBackup(oSQLServer);
}
catch (Exception e)
{
throw new Exception(e.ToString());
}
finally
{
oSQLServer.DisConnect();
}
} --------------------编程问答-------------------- 可能图片看不清,我把错误代码贴出来。请各位帮看看。
Server Error in '/' Application.--------------------------------------------------------------------------------
Retrieving the COM class factory for component with CLSID {10021F00-E260-11CF-AE68-00AA004A34D5} failed due to the following error: 80070005.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {10021F00-E260-11CF-AE68-00AA004A34D5} failed due to the following error: 80070005.
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
Source Error:
Line 37: public static void SQLBACK(string ServerIP, string LoginName, string LoginPass, string DBName, string BackPath)
Line 38: {
Line 39: SQLDMO.Backup oBackup = new SQLDMO.BackupClass();
Line 40: SQLDMO.SQLServer oSQLServer = new SQLDMO.SQLServerClass();
Line 41: try
Source File: d:\wwwroot\rencaiwang\web\App_Code\BLL\DataBak.cs Line: 39
--------------------编程问答-------------------- 好像是网站类的,这里有备份数据库文件的代码:http://blog.csdn.net/xianfajushi/archive/2008/10/18/3094821.aspx可参考
补充:.NET技术 , ASP.NET