日期:2014-05-18  浏览次数:20421 次

备份数据库时连接数据库出错
错误信息为:
[Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server 不存在或访问被拒绝
[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()).

代码如下:
C# code

SQLDMO.Backup oBackup = new SQLDMO.BackupClass();
            SQLDMO.SQLServer oSQLServer = new SQLDMO.SQLServerClass();
            try
            {
                oSQLServer.LoginSecure = false;
                oSQLServer.Connect("127.0.0.1", "sa", "123");
                oBackup.Action = SQLDMO.SQLDMO_BACKUP_TYPE.SQLDMOBackup_Database;
                oBackup.Database = dbName;
                oBackup.Files = @"backup\" + backupDBName + ".bak";
                oBackup.BackupSetName = backupDBName;               
                oBackup.BackupSetDescription = "数据库备份";
                oBackup.Initialize = true;            
                oBackup.SQLBackup(oSQLServer);               
            }


------解决方案--------------------
http://www.cnblogs.com/njnudt/archive/2007/03/18/678880.html
------解决方案--------------------
没办法,自己检查网络问题,检查用户名,是启用了sa权限