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");
}
}
}
例如,我在数据库中有一个Fname Smith
,然后在NametextBox中键入Smith
,messageBox将显示。但是当我输入smith
或SMITH
时,它仍会读取。我该怎么做才能使读者区分大小写?
答案 0 :(得分:1)
尝试更改排序规则,例如
Select * from Emp where Fname COLLATE Latin1_General_CS_AS = @Fname