title: Cannot convert input string to Int64 in ASP.NET using store procedures
body: <p>I have used the store procedure in MS-Sql for inserting for particular page it is working fine but I also need the same store procedure for other page it is finding me the error.</p>
  
  <pre><code>protected void btnsubmitt_Click(object sender, EventArgs e)
  {
      ArrayList arParameters = ReturnParameter();
      DataSet dsInsertProfile = objadmin.GetGridData(arParameters,                    objconstant.sSP_INSERT_PROFILE);
  
      if (int.Parse(dsInsertProfile.Tables[0].Rows[0].ItemArray[0].ToString()) == 0)
      {
          pnlProfile.Visible = false;
          pnlThank.Visible = true;
          lblThank.Text = "Your profile have been successfully saved.";
      }
  
      else
      {
          lblThank.Text = "Your profile is not saved, please try again later.";
      }
  
  }
  public ArrayList ReturnParameter()
  {
      Int64 email = Convert.ToInt64(txtemail.Text.ToString());
      ArrayList arSample = new ArrayList();
      Object[] c_email_id = new Object[3] { "@strEmailID", "varchar", email};
       arSample.Add(c_email_id);
       return arSample;
  }
    public DataSet GetGridData(ArrayList dbArray, string sSpName)
      {
          DataSet dsDataSet = new DataSet();
          dsDataSet = datamanager.GetGridData(dbArray, sSpName);
          return dsDataSet;
      }
      public static DataSet GetGridData(ArrayList dbArray, string sSpName)
      {
          DataSet dsDataSet = new DataSet();
          SqlConnection cn = createConnection();
          SqlCommand cmd = new SqlCommand();
          cmd.CommandType = CommandType.StoredProcedure;
          cmd.CommandText = sSpName;
  
          object objPrMtrName;
          object objSqlType;
          object objPrMtrVal;
          int i;
          for (i = 0; i &lt; dbArray.Count; i++)
          {
              objPrMtrName = ((object[])(dbArray[i]))[0];
              objSqlType = ((object[])(dbArray[i]))[1];
              objPrMtrVal = ((object[])(dbArray[i]))[2];
              cmd.Parameters.Add(objPrMtrName.ToString(), GetSqlDataType(objSqlType.ToString())).Value = objPrMtrVal;
          }
          cmd.Connection = cn;
          try
          {
              SqlDataAdapter adp = new SqlDataAdapter(cmd);
              adp.Fill(dsDataSet);
              return dsDataSet;
          }
          catch (Exception ex)
          {
              throw ex;
          }
          finally
          {
              cn.Close();
              cn.Dispose();
          }
      }
  </code></pre>
  
  <p>Mystore procedure</p>
  
  <pre class="lang-sql prettyprint-override"><code>ALTER Procedure [dbo].[spInsert_profile]
  (  @strEmailID varchar(200)
  
  )
   AS
  BEGIN
      DECLARE @intEmail INT
  SET @intEmail = (SELECT COUNT(*) FROM gdt_Users WHERE [c_email_id]=@strEmailID)        
  IF @intEmail = 0
   BEGIN
  
         Insert into gdt_Users([c_email_id],[d_modified_dttm],[d_created_dttm])values(@strEmailID,GETDATE(),GETDATE())
  
   SELECT @intEmail
    END
  ELSE
      BEGIN
          SELECT @intEmail
  
      END
  END
  </code></pre>
  
  <p>Here, I was facing a problem. It was throwing an exception </p>
  
  <pre class="lang-none prettyprint-override"><code>ERROR: Failed to convert parameter value from string to Int64 
  </code></pre>
  
  <p>So, I've add this code </p>
  
  <pre class="lang-cs prettyprint-override"><code>Int64 email = Convert.ToInt64(txtemail.Text.ToString());
  </code></pre>
  
  <p>in arraylist <code>returnparameter()</code> method. Then, it threw that exception</p>
  
  <pre class="lang-none prettyprint-override"><code>ERROR: Input string was not in correct format
  </code></pre>
  
  <p>How can I solve this? Can you help me?</p>