Need to retrieve and convert to an integer using SELECT SCOPE_IDENTITY : <p>I'm trying to match the users ID (pk) on the 'users' table, with the users ID (fk) on the 'owners' table, but it seems to not be working.</p>

<p>But it gives me and error on the dono (onwer) saying that I need to convert it.</p>

<pre><code> protected void confirmarButton_Click(object sender, EventArgs e)
    {
        int n = 0;

        if (primeiroNome.Text != "" &amp; nomeDoMeio.Text != "" &amp;&amp; sobrenome.Text != "" &amp;&amp; dataDeNascimento.Text != "" &amp;&amp; enderecoPostal1.Text != "" &amp;&amp; cidade.Text != "" &amp;&amp; email.Text != "" &amp;&amp; username.Text != "" &amp;&amp; password.Text != "" &amp;&amp; confirmarPassword.Text != "")
        {
            if (password.Text == confirmarPassword.Text)
            {
                String CS = ConfigurationManager.ConnectionStrings["ClinicaAnimal"].ConnectionString;
                using (SqlConnection con = new SqlConnection(CS))
                {

                    n = userIdNumber();


                    SqlCommand cmd2 = new SqlCommand("Insert into Users ([Username], [Password],[Tipo de User])Values('" + username.Text + "','" + Encrypt(password.Text.Trim()) + "','" + "Dono" + "')", con);
                   // cmd2.Parameters.AddWithValue("@Password", Encrypt(password.Text.Trim()));
                    SqlCommand cmd = new SqlCommand("Insert into Dono ([Primeiro Nome], [Nome do Meio], [Sobrenome], [Data de Nascimento], [Endereço Postal1], [Endereço Postal2], [Cidade], [Email], [UserID])Values('" + primeiroNome.Text + "','" + nomeDoMeio.Text + "','" + sobrenome.Text + "','" + dataDeNascimento.Text + "','" + enderecoPostal1.Text + " ','" + enderecoPostal2.Text + " ','" + cidade.Text + " ','" + email.Text + "','"+ "SELECT SCOPE_IDENTITY()" +"')", con);


                    con.Open();

                    cmd2.ExecuteNonQuery();
                    cmd.ExecuteNonQuery();


                    Response.Redirect("~/Home.aspx");
                }
            }
            else
</code></pre>
