I have problem searching for a long string that contains special character in MS Access. Here is my sample data.
staff_Id | hashValue
1 | 4ENOA2838F09dbfTKXeAdEIKRM91MdsDg0W4pRNChdkGa7iwoVifWH9avZdjrPp1QqLJ0ecNe/X716HlwqfSYA==
Here is my SQL command.
SELECT *
FROM table
WHERE hashValue='4ENOA2838F09dbfTKXeAdEIKRM91MdsDg0W4pRNChdkGa7iwoVifWH9avZdjrPp1QqLJ0ecNe/X716HlwqfSYA==';
I had tried googling for escape characters, however I cannot get this working. Hope that you can help me. Thank you.
P.S. I am developing a C# program that interacts with MS-access
UPDATE
Here is my SQL query in my C# program that execute the search query.
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
}
}
in C# try writing the command like this:
notis the @ mark before the string. this allows you to have string that look like this:
In your case you can do it like this:
but the @-trick works best if its set when the string is declared.