Link to home
Start Free TrialLog in
Avatar of Jose Castaneda
Jose Castaneda

asked on

Plain Sight SQL Connection String within Excel VBA Code? No way!!!

I had this question after viewing SHA 224 on excel.

I started to program/build an Excel template with a plain sight SQL Connection String within its VBA Code, but now I need to learn how to use a hash to hide its ID and Password. However, I do not know the required steps to make it work within VBA Excel: Should I store the hash somewhere else?, Should I compare that hash with the one inside the VBA?, and the most important step how to make a query and the SQL will recognize the true Password if in the Excel VBA code is only the hash string? Can somebody elaborate on how to do that in my VBA Excel/SQL Server situation?  On the other hand, this VBA code in the post looks fantastic, and I have found it on several other sites, but the Function Nz(sMessage, "") stops the run in error since it is nowhere to be found within this code. Please, SMEs help is really appreciated.

Thanks!
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Who should know the password?
I think the best option is to don't provide a password and let the user type the password every time he or she is using the application.
I've added VBA topic to call for the right Experts.
Avatar of Jose Castaneda
Jose Castaneda

ASKER

The requirements call for this hash solution, it is not within my authority to change them. They do not want every single user with a different ID and Password. Thanks for your reply!
There's a VBA hash function that you can use. Check if this article helps: https://en.wikibooks.org/wiki/Visual_Basic_for_Applications/String_Hashing_in_VBA
Your problem with the NZ() function in that code sample is that NZ() is specific to Microsoft Access VBA (returns a "value to use if null") and doesn't exist for Excel.

If you pass sMessage to the hash function as type string  you should not need the NZ line.
Jose, is this issue solved or do you need further help from us?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.