Social Icons

Pages

Monday, October 17, 2011

Process of creating publication

This article provides step by step configuring  publication in SQL Server 2008R2
  1. Open SQL Server Management Studio, connect to the publication server and expand the replication folder.
  2. Inside of the Replication folder, Right-click on the publication and select ‘New publication
         3.  The “Create Publication Wizard” starts, press “Next” button.   
         4.  In the next window, select the database that you wish to create a publication and click ‘Next’ button.

              5. In the publication type, select the publication type <merge publication> that you wish to use and click   ‘Next’ button.

               6. On the subscriber type’s window, specify the Subscriber Types. Select Servers running <SQL Server 2008> then click ‘Next’ button.

                 7. Select the Object Types (like Tables, Stored Procedures and Views) which you want to publish, and  click ‘Next’ to continue.

                   8. Then it will show some issues which may require some changes at later stages in order to work as expected. Just click ‘Next’ to continue.

                Adding Filters   
                • On the Filter table rows window, click ‘add’ button to add filter table 
                  •   Then select the table, column and set the parameter and click ok button.
                  Here I’m using Rephost coloumn and parameter =<rephost=HOST_NAME> 

                       9. Then it will display snapshot agent screen, select snapshot agent type and click next button to continue.
                     
                         10. Then select the security agent type and click next button to continue.

                    Snap shot agent security settings
                    • Specify the domain or machine account and set the connection type.

                         11. Then it will display wizard action screen, select the option and click next button to continue.
                       

                           12. Then enter the publication name and select Click Finish to create a Publication

                      Thursday, October 13, 2011

                      Setting up Replication in SQL Server 2008 R2

                      Replication is one of the accessibility features available in SQL Server. And it allows database administrators to distribute data to various servers throughout an organization.

                      In this article, I will demonstrate the step by step approach to configuring replication in SQL Server 2008R2 Before we start with the configuration, we need to understand three important terms:

                      • Publisher- Publishers have data to offer to other servers. Any given replication scheme may have one or more publishers.
                      • Subscriber- Subscribers are database servers that wish to receive updates from the Publisher when data is modified. The subscriber database normally resides on a different server in another location.
                      • Distribution Database- A database that contains all the Replication commands database can reside on the same server as the publisher, but it is always recommended to keep them on a separate server for better performance. Normally, when you hold the distribution database on the same machine as the publisher database if there are many publishers and publishers are always an impact on the performance of the system. This is because, for each publisher, one distrib.exe file is created.

                      Microsoft SQL Server supports the following three types of database replication
                      Merge replication: 
                      The Merge replication is used when both Publisher and Subscriber need to make changes to their personal databases. In this case both databases might have been changed between runs of the Merge SQL replication, and the replication merges the changes in both locations. Of course when using merge replication you should be aware that there might be conflicts, for example duplicated primary keys. If there is a conflict, then the merge replication follows predetermined conflict resolution plan to correct the issue. 
                      Transactional replication:
                      The Transactional replication is usually used with databases where data changes frequently and there’s need for constant refreshing of the data. The replication process watches the publisher’s database for any changes, if there are changes; it distributes them over to the replication subscribers.
                      Snapshot replication:
                      Snapshot replication acts in the manner its name implies. The publisher simply takes a snapshot of the entire replicated database and shares it with the subscribers. Of course, this is a very time and resource-intensive process. For this reason, most administrators don’t use snapshot replication on a recurring basis for databases that change frequently. There are two scenarios where snapshot replication is commonly used. First, it is used for databases that rarely change. Second, it is used to set a baseline to establish replication between systems while future updates are propagated using transactional or merge replication.



                      Wednesday, October 12, 2011

                      Easiest way to detect an open form in C#

                      During winforms programming, where you do not want to open a form multiple forms.
                      Here is a way to check there is already a form open before opening a new one.
                      public partial class MainForm : Form
                      {     
                              private Frm_ Form frm_Form;

                      private void OpenForm()           
                             {

                                  if (frm_Form != null)               
                                  {
                                      if (frm_Form.IsDisposed == false)
                                      {
                                         frm_Form.Activate();
                                      }
                                      else
                                      {
                                         frm_Form = new Frm_ Form ();
                                         frm_Form.Show();
                                      }
                                  }
                                  else
                                  {
                                         frm_Form = new Frm_ Form ();
                                         frm_Form.Show();
                                  }
                                    

                             }
                      }

                      Tuesday, October 11, 2011

                      Numeric validation

                      Here's a small method for validating numeric in C#. It may save you some time.
                      public static bool DecimalInputValidation(TextBox textBox, KeyPressEventArgs e)
                      {
                      try
                                  {
                                      if (e.KeyChar == (char)8 || e.KeyChar == (char)46)
                                      {
                                          e.Handled = false;
                                          return true;
                                      }
                                      if (e.KeyChar >= (char)48 && e.KeyChar <= (char)57)
                                      {
                                            string val = textBox.Text;
                                          val = val + e.KeyChar.ToString();
                                          decimal intVal = 0;
                                          bool con = decimal.TryParse(val, out intVal);
                                          if (con)
                                          {
                                              e.Handled = false;
                                              return true;
                                          }
                                          else
                                          {
                                              e.Handled = true;
                                              return false;
                                          }
                                      }
                                      e.Handled = true;
                                      return false;
                                   }
                                  catch (Exception exp)
                                  {
                                      throw exp;
                                  }
                      }