Invalid cast exception on remote server Guid to string
<p>I have this code in my project:</p>

<pre><code>string userId = Membership.GetUser(username).ProviderUserKey.ToString();
SqlConnection conn = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand("UPDATE aspnet_Membership SET IsLockedOut = 0, LastLockoutDate = @LastLockedOutDate WHERE UserId = @Userid", conn);
cmd.Parameters.Add("@LastLockedOutDate", SqlDbType.DateTime).Value = DateTime.Now;
cmd.Parameters.Add("@Userid", SqlDbType.VarChar, 255).Value = userId;
int rowsAffected = 0;
conn.Open();
rowsAffected = cmd.ExecuteNonQuery();
</code></pre>

<p>This works fantastic on my local machine. The user gets unlocked no problem. But for some reason when I deploy it to a demo site on the remote server I get this error:</p>

<pre><code>InvalidCastException: Failed to convert parameter value from a Guid to a String
</code></pre>

<p>It's failing on the cmd.ExecuteNonQuery line. I tried changing the parameter to a uniqueidentifier and passing the actual guid but that didn't work either.</p>

<p>Anybody know why this would work locally but not on a remote server? Or know of a way I can modify the code to possibly work?</p>
