Pergunta

using (SqlConnection myDatabaseConnection = new SqlConnection(myConnectionString.ConnectionString))
{
    myDatabaseConnection.Open();

    using (SqlCommand mySqlCommand1 = new SqlCommand("Select * from Emp where Fname = @Fname", myDatabaseConnection))
    {
        mySqlCommand1.Parameters.AddWithValue("@FName", NametextBox.Text);
        SqlDataReader DR1 = mySqlCommand1.ExecuteReader();
        if (DR1.Read())
        {
            MessagabeBox.Show("TEST");
        }
    }
}

For example I have a Fname Smith in the database and then I type Smith in the NametextBox, the messageBox will show. But when I type smith or SMITH, it still reads. What will I do to make the reader case sensitive?

Foi útil?

Solução

try changing the collation, eg.

Select * from Emp where Fname COLLATE Latin1_General_CS_AS = @Fname
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top