Need help with String query (OLEDB)

Good afternoon All,

I have an issue where I can query my Excel table as DB by implementing the OLEDB driver. I can query using the hard-coded string. But unfortunately can not query using the variable in my String as I need to pass variables from another workflow to look up for a data in my excel sheet.

"SELECT [First], [Middle], [Last] FROM [SAM_Exclusions_Public_Extract_1$] WHERE [First] = “+firstName+”[Middle] = “+middleName+”[Last] = “+lastName+”;"

This is how my query looks like where firstName, middleName and last Name are variables. Any help in resolving this issue is appreciated.

Below is the error message I get when executing the query:


Hi @Thrall
You were almost right…but with a small correction as the query should be like this buddy
"SELECT [First], [Middle], [Last] FROM [SAM_Exclusions_Public_Extract_1$] WHERE [First] = ’ “+firstName+” ’ and [Middle] = ’ “+middleName+” ’ and [Last] = ’ “+lastName+” ’ "


Hi @Palaniyappan,

Thank you very much :slight_smile: It did resolved my issue.

1 Like

Cheers @Thrall


Now I have another issue, the query executes, but it returns all the results with the same name. Even if I already pass the value in the variable. So let us assume that I have First name = John and Last name Smith, if I pass them in the query string as variables the result of the query will be all the Johns with different last names. Any help or hint to resolve this issue is appreciated. On the other hand, if I pass them explicitly the results of the query will be John Smith. One more thing the result of the query is always returning the column names as well. If I queried for John Smith, the result will be First Last John Smith


Never mind it was my dumb typo mistake in my query string, I corrected it and it is working like a charm, thank you very much!

1 Like

Fantastic buddy @Thrall

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.