关于数据备份问题
我想把数据备份,但是总是出现一下错误,不知道是什么原因。请高手指教、代码如下:private void Linkbutton3_Click(object sender, System.EventArgs e)
{
//数据库备份
string syspath = Server.MapPath("~/data/");
SQLBACK("127.0.0.1", "sa", "", "peisong", syspath );
}
protected void SQLBACK(string ServerIP, string LoginUserName, 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, LoginUserName, LoginPass);
oBackup.Action = 0;
oBackup.Database = DBName;
oBackup.Files = @" " + BackPath + "peisong.bak";
oBackup.BackupSetName = DBName;
oBackup.BackupSetDescription = "数据库备份";
oBackup.Initialize = true;
oBackup.SQLBackup(oSQLServer);
Response.Write("<script>alert('数据备份成功!')</script>");
}
catch (Exception e)
{
throw new Exception(e.ToString());
}
finally
{
oSQLServer.DisConnect();
}
}
“/zyp”应用程序中的服务器错误。
--------------------------------------------------------------------------------
System.Runtime. (0x80040000): [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server 不存在或访问被拒绝 [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). at SQLDMO.SQLServerClass.Connect(Object ServerName, Object Login, Object Password) at zyp.left.SQLBACK(String ServerIP, String LoginUserName, String LoginPass, String DBName, String BackPath) in e:\ps\zyp\left.aspx.cs:line 243