09-21-2012, 04:27 PM
I am writing a script to compare values in an excel file and values retrieved from a SQL database
The value in question is - "A the HR. (No Ad)"
The value is taken directly from SQL query and copied into the excel sheet for comparison purposes.
When I read the value from the excel sheet (also using OLEDB connection for Excel) it is displayed as
"A the HR. (No Ad)" (A)
But when I read the value from SQL using connection string the value is displayed as
"A the HR.(No Ad)" (B)
Even though the value in the DB is displayed correctly as (A) which is as expected using a query search.
For some reason when getting the value using connection string the space is removed from the string.
- If I remove the space using replace or trim the If A=B statement still fails (even though the 2 strings are now the same)
- I have tried searching for a vbCrlf in the string and removing it but still the condition fails.
Can anyone explain this wierd behaviour and give a solution?
Thanks,
Charan
The value in question is - "A the HR. (No Ad)"
The value is taken directly from SQL query and copied into the excel sheet for comparison purposes.
When I read the value from the excel sheet (also using OLEDB connection for Excel) it is displayed as
"A the HR. (No Ad)" (A)
But when I read the value from SQL using connection string the value is displayed as
"A the HR.(No Ad)" (B)
Even though the value in the DB is displayed correctly as (A) which is as expected using a query search.
For some reason when getting the value using connection string the space is removed from the string.
- If I remove the space using replace or trim the If A=B statement still fails (even though the 2 strings are now the same)
- I have tried searching for a vbCrlf in the string and removing it but still the condition fails.
Can anyone explain this wierd behaviour and give a solution?
Thanks,
Charan