title: Inserting Data into database using Web Service
body: <p>I am developing browser helper object to get client information like IP, URL, data time, etc. I am getting this information but it can't store it to the database. For storing purpose I use web service to store data into database. Web service direct store information correctly but getting information from bho it can't store data into database. And not showing any error, I don't know what's the problem.</p>
  
  <p>This is my code:</p>
  
  <pre><code>using System;
  using System.Threading.Tasks;
  using SHDocVw;
  using mshtml;
  using System.Runtime.InteropServices;
  using Microsoft.Win32;
  
  namespace MyBHO
  {
      [
      ComVisible(true),
      Guid("8a194578-81ea-4850-9911-13ba2d71efbd"),
      ClassInterface(ClassInterfaceType.None)
      ]
      public class BHO : IObjectWithSite
      {
  
          string ip = new 
          System.Net.WebClient().DownloadString("http://icanhazip.com");
          string  datetimenow = DateTime.Now.ToShortDateString();
          WebBrowser webBrowser;
          HTMLDocument document;
  </code></pre>
  
  <p>In this function I send data to web service to save data into database but when bho running it displays data on form but not storing in database.</p>
  
  <pre><code>public void OnDocumentComplete(object pDisp, ref object URL)
  {
      document = (HTMLDocument)webBrowser.Document;
      System.Windows.Forms.MessageBox.Show("your log infomation: :" + ip+ "/n" + URL.ToString() + "/n"+ datetimenow);
      logReciever.LogRecieverSoapClient client = new logReciever.LogRecieverSoapClient();
      client.insertData(URL.ToString(), ip, datetimenow);
  
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>public int SetSite(object site)
  {
      if (site != null)
      {
          webBrowser = (WebBrowser)site;
          webBrowser.DocumentComplete +=
            new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
          webBrowser.BeforeNavigate2 +=
             new DWebBrowserEvents2_BeforeNavigate2EventHandler(this.OnBeforeNavigate2);
      }
      else
      {
          webBrowser.DocumentComplete -=
            new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
          webBrowser.BeforeNavigate2 -=
            new DWebBrowserEvents2_BeforeNavigate2EventHandler(this.OnBeforeNavigate2);
          webBrowser = null;
      }
      return 0;
  }
  </code></pre>
  
  <p>Advance thanks for helping.</p>