Wednesday 30 July 2014

Drag window by clicking anywhere - WPF

XAML

MouseDown="Window_MouseDown_1"


.CS
 private void Window_MouseDown_1(object sender, MouseButtonEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                this.DragMove();
            }
        }

Thursday 17 July 2014

How to copy whole database to another database on some other server

  void transfer(string table_name)
        {
            // Establishing connection

            SqlConnection cnn = existing_database;

            // Getting source data
            SqlCommand cmd = new SqlCommand("SELECT * FROM " + table_name, cnn);
            cnn.Open();
            SqlDataReader rdr = cmd.ExecuteReader();

            // Initializing an SqlBulkCopy object
            SqlBulkCopy sbc = new SqlBulkCopy(destination_database);

            destination_database.Open();
            // Copying data to destination
            sbc.DestinationTableName = table_name;
            sbc.WriteToServer(rdr);

            // Closing connection and the others
            sbc.Close();
            rdr.Close();
            cnn.Close();

        }

Enjoy :) Jai Mata Di, Jai SiyaRam