在 MS Access 中搜索包含特殊字符的长字符串时遇到问题。这是我的示例数据。
staff_Id | hashValue
1 | 4ENOA2838F09dbfTKXeAdEIKRM91MdsDg0W4pRNChdkGa7iwoVifWH9avZdjrPp1QqLJ0ecNe/X716HlwqfSYA==
这是我的 SQL 命令。
SELECT *
FROM table
WHERE hashValue='4ENOA2838F09dbfTKXeAdEIKRM91MdsDg0W4pRNChdkGa7iwoVifWH9avZdjrPp1QqLJ0ecNe/X716HlwqfSYA==';
我曾尝试在谷歌上搜索转义字符,但我无法正常工作。希望你能帮助我。谢谢你。
PS 我正在开发一个与 MS-access 交互的 C# 程序
更新
这是我的 C# 程序中执行搜索查询的 SQL 查询。
string sqlStatement = "SELECT * FROM table WHERE hashValue = @hashedValue";
using (OleDbConnection connection = new OleDbConnection(connString))
{
using (OleDbCommand command = new OleDbCommand())
{
command.Connection = connection;
command.CommandText = sqlStatement;
command.Parameters.AddWithValue("@hashedValue", hashedValue);
ds = new DataSet(); //have been declared
dbAdapter = new OleDbDataAdapter(); //have been declared
dbAdapter.SelectCommand = command;
dbAdapter.Fill(ds, "table"); //empty dataset here
}
}