title: Converting data type nvarchar to int
body: <p>I have this stored procedure :</p>
  
  <pre><code>CREATE PROCEDURE SearchEmployee
          @EmployeeID int,
          @EmployeeName nvarchar(256),
          @Address nvarchar(256),
  AS
      Select 
          EmployeeId, EmployeeName, Address 
      From 
          Employee
      Where
          EmployeeID = @EmployeeID OR
          EmployeeName LIKE '%' + @EmployeeName+ '%' OR
          Address LIKE '%' + @Address+ '%' 
  </code></pre>
  
  <p>Then in my Winforms I call it like this:</p>
  
  <pre><code>using (SqlCommand mySqlCommand1 = new SqlCommand("dbo.SearchEmployee", myDatabaseConnection))
  {
              mySqlCommand1.CommandType = CommandType.StoredProcedure;
              {
                  mySqlCommand1.Parameters.AddWithValue("@EmployeeID", textBox1.Text);
                  mySqlCommand1.Parameters.AddWithValue("@EmployeeName", textBox1.Text);
                  mySqlCommand1.Parameters.AddWithValue("@Address", textBox1.Text);
              }
          }
  </code></pre>
  
  <p>How I will avoid the error </p>
  
  <blockquote>
    <p>Error converting data type  nvarchar to int.</p>
  </blockquote>
  
  <p>When a user type a employee name instead of <code>EmployeeID</code>?</p>
  
  <p>I tried this in my stored procedure:</p>
  
  <pre><code>EmployeeID = cast(@EmployeeID as varchar(10))
  </code></pre>