1
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");
        }
    }
}

例如,我Smith在数据库中有一个 Fname,然后我输入SmithNametextBox,messageBox 将显示。但是当我输入smithor时SMITH,它仍然会显示。我将如何使读者区分大小写?

4

1 回答 1

1

尝试更改排序规则,例如。

Select * from Emp where Fname COLLATE Latin1_General_CS_AS = @Fname
于 2013-09-08T20:21:42.090 回答