private void btnBackup_Click(object sender, EventArgs e)
        {
            Backup bkp = new Backup();

            this.Cursor = Cursors.WaitCursor;
            this.dataGridView1.DataSource = string.Empty;
            try
            {
                string fileName = this.txtFileName.Text;
                string databaseName = this.ddlDatabase.SelectedItem.ToString();

                bkp.Action = BackupActionType.Database;
                bkp.Database = databaseName;
                bkp.Devices.AddDevice(fileName, DeviceType.File);
                bkp.Incremental = chkIncremental.Checked;
                this.progressBar1.Value = 0;
                this.progressBar1.Maximum = 100;
                this.progressBar1.Value = 10;

                bkp.PercentCompleteNotification = 10;
                bkp.PercentComplete += new PercentCompleteEventHandler(ProgressEventHandler);

                bkp.SqlBackup(srv);
                MessageBox.Show("Database was successfully backed up to: " + fileName, "Info");
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                this.Cursor = Cursors.Default;
                this.progressBar1.Value = 0;
            }
        }

tnx im in andvance im in rush!!

U have to use one more option that is Connection, if it is Windows Authentication U have to Use,

MyServer = new Server(SName[i]);
MyServer.ConnectionContext.LoginSecure = true;
MyServer.ConnectionContext.Connect();

or if the Mode is Sql Server Authentication, then u have to give,

ServerConnection Conn = new ServerConnection(SName[i]);
Conn.LoginSecure = false;
Conn.Login = UID[i].ToString();
Conn.Password = PWD[i].ToString();
MyServer = new Server(Conn);

Hope it will help U.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.