title: Cannot implicitly convert type string to System.Collections.Generic.Dictionary<string,System.Collections.Generic.Dictionary><string,object>>
body: <p>I am getting an error near <code>return errmsg(ex);</code>:</p>
  
  <blockquote>
    <p>cannot implicitly convert type string to
    system.collections.generic.dictionary></p>
  </blockquote>
  
  <p>Here is my code:  </p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Services;
  using System.Web.Script.Serialization;
  using System.Web.Script.Services;
  using System.Data;
  using System.Data.SqlClient;
  using System.Configuration;
  using System.ComponentModel;
  
  
  namespace Webservice
  {
      /// &lt;summary&gt;
      /// Summary description for Service1
      /// &lt;/summary&gt;
      [WebService(Namespace = "http://tempuri.org/")]
      [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
      [ToolboxItem(false)]
      // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
      // [System.Web.Script.Services.ScriptService]
      public class Service1 : System.Web.Services.WebService
      {
          public Service1()
          {
              //Uncomment the following line if using designed components 
              //InitializeComponent(); 
          }
          [WebMethod]
          [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
          //public string GetEmployees(string SearchTerm) 
          private static Dictionary&lt;string, Dictionary&lt;string, object&gt;&gt; DatatableToDictionary(DataTable dt)
          {
              var cols = dt.Columns.Cast&lt;DataColumn&gt;();
              return dt.Rows.Cast&lt;DataRow&gt;()
                       .ToDictionary(r =&gt; dt.Rows.IndexOf(r).ToString(),
                                     r =&gt; cols.ToDictionary(c =&gt; c.ColumnName, c =&gt; r[c.ColumnName]));
          }
          public Dictionary&lt;string, Dictionary&lt;string, object&gt;&gt; GetEmployees()
          {
              try
              {
                  SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["NSConstr"].ToString());
                  con.Open();
                  SqlCommand cmd = new SqlCommand();
                  //cmd.CommandText = "SELECT *  FROM Contact e WHERE FirstName LIKE '%" + SearchTerm + "%'";
                  cmd.CommandText = "SELECT *  FROM Contact e ";
                  DataSet ds = new DataSet();
                  SqlDataAdapter da = new SqlDataAdapter(cmd);
                  da.SelectCommand.Connection = con;
                  da.Fill(ds);
                  con.Close();
  
                  return DatatableToDictionary(ds.Tables[0]);
              }
              catch (Exception ex)
              {
                  ***return errmsg(ex);***
  
              }
          }
  
          public string errmsg(Exception ex)
          {
              return "[['ERROR','" + ex.Message + "']]";
          }
       }
   }
  </code></pre>
  
  <p>Thanks in advance.</p>