Hello. I have a .TXT file. I want to make a code in VBA that will read . TXT and send this information to MYSQL. I created a ODBC driver but how can i connect it using VBA and then, atrributes a value to a table in SQL??
The best way to connect to a database using vba is ado.
You should be able to use ADO to connect to the database directly. The hard part is the connection string use to access the database. Here is a link that will show some connection string examples: http://www.carlprothman.net/Default.aspx?tabid=81
Just remember that you will check the ado in the reference library in the vb editor to use the ado objects.
I would use the ado command object and create a store procedure in database itself. Then all you would have to do is pass the parameters and execute it.
It makes it a lot easier than trying to write the sql in vba. It can be very tricky. Plus it lets the database do the work and all you do is pass values. Better performance than trying to hard parse an sql string. I will see if I can come up with some specific example for this.