ODBC connection with Visual Basic

Sometimes it could happen that you need directly access to a local ODBC database in your Visual Basic project and do to the fact that I wasn’t able to find much on the web about this topic, I decided to post something about it.

In order to do so you need to first import the “data.odbc” and “system.data” and then you have to set the connection string in order to directly access to your database.

In my case the database was on my pc (localhost) the DSN name was “Name” and the credentials were “root” and “password”. Of course you will have to change those parameters in order to match to your ODBC settings (see the string called “ODBCString “)

The example below rapresents a basic connection to a local ODBC database.