title: Populate the textbox value based on another textbox from database
body: <p>i'm trying to populate textbox value based on another textbox but i cannot populate the the other textbox. i'm sharing my code please guide me with best solution</p>
  
  <p>Action Method:</p>
  
  <pre><code>public JsonResult AgreementNo(string id)
  {
      string no;
      string _str = id;
      SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString());
      SqlCommand cmd = new SqlCommand("SELECT top(1) num from loan where id=@str", con);
      cmd.Parameters.AddWithValue("@str",id);
      cmd.CommandType = CommandType.Text;
      DataSet ds = new DataSet();
      SqlDataAdapter da = new SqlDataAdapter(cmd);
      da.Fill(ds);
      no = ds.Tables[0].Rows[0]["num"].ToString();
      return Json(new
          {
           no = no
          }, JsonRequestBehavior.AllowGet);
      }
  </code></pre>
  
  <p>Script:</p>
  
  <pre><code> $("#BarrowerName").blur(function () {                    
   $.ajax({                      
   url: '@Url.Action("AgreementNo", "Home")',
   // url: '@Url.Action("AgreementNo", "Home")',
   dataType: "json",
   data: JSON.stringify({ id: $("#BarrowerName").val() }),
   type:"POST",
   async: false,
   contentType: 'application/json,charset=utf-8',
   sucess: function (data) {
   $("#AgreementNo").val(data.no)
   response(data);
  }
  });                           
  });
  </code></pre>
  
  <p>It Throwing the error like:Conversion failed when converting the nvarchar value '' to data type int.</p>