Click here to Skip to main content
16,020,459 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
i am able to backup and restore local sqlserver database
when i go for remote server then time i want to use my same code
i want change only servername in connection string
i am using code-

XML
<add key ="BACKUP_DATABASE_SERVER" value ="Data Source=admin\SQLEXPRESS;User ID=****;Password=****;"/>


when i connect using SERVER class
C#
SERVER_NAME=admin\SQLEXPRESS;
 Server srv = new Server(SERVER_NAME);

            //DataTable dtServers = SmoApplication.EnumAvailableSqlServers(true);

            
            ServerConnection srvConn = srv.ConnectionContext;
            srvConn.LoginSecure = true;
            //string strBackupDir = srv.Settings.BackupDirectory;
            DatabaseCollection objDatabases =srv.Databases;

this code gives error on first line

Login failed to server


Thank You
Posted
Updated 27-May-11 3:55am
v2

1 solution

It means that your UserID and Password combination is not valid for the server you are trying to hit. Errors like this are pretty much self-explanatory.
You asked basically the same question a couple of hours ago. In the future, you should just update the existing question instead of creating a new one when they are this similar.

Cheers.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900