Connecting to the MySQL database using ODBC
DSN-less connections are great for portability; however, as mentioned earlier, the connection's login details are in the Excel workbook. This can be a security risk if your data is sensitive. Another issue is that they will work for anyone who happens to get hold of the spreadsheet. As long as the relevant driver is on their computer, the driver details are also in the connection routine, so someone with a little ODBC and VBA knowledge will figure that out quickly.
In the next exercise, we will create a new function to connect to the database using a DSN.
Exercise 12.01 – creating a DSN connection function
A DSN offers more security; you need to set up the connection on the user's computer before they can use the spreadsheet. When using a DSN, the login details are not visible in the workbook. Also, as a bonus for you, the developer, it requires less coding to use in your application.
In this exercise, we will...