title: How do i convert an int retrieved from a database to string
body: <p>I have a login form that I wanna select the <code>userID</code> (which is in the form of an <code>int</code>) from the database, and store it as a <code>string</code>.</p>
  
  <pre><code>string insertQuery = 
    "SELECT UserID FROM Customers WHERE Email = @Email AND Password = @Password";
  
  SqlCommand com = new SqlCommand(insertQuery, conn);
  
  com.Parameters.AddWithValue("@Email", tbEmail.Text);
  com.Parameters.AddWithValue("@Password", tbPassword.Text);
  
  string result = (string)com.ExecuteScalar();
  </code></pre>
  
  <p>But after I login, I get <strong>this error</strong>: </p>
  
  <blockquote>
    <p>System.InvalidCastException: 'Unable to cast object of type
    'System.Int32' to type 'System.String'.</p>
  </blockquote>