![]() Sqlstr = "INSERT INTO " & table1 & " SET " _ ' Write new entries to a table from the first sheet of the workbook With Worksheets(1).Cells ' Enter your sheet name and range here Sqlstr = "SELECT * FROM " & table1 ' extracts all data ' Extract MySQL table data to first worksheet in the workbook ' Erase entire table contents but do not remove the table ' Add, remove or extract records from an existing table Sqlstr = "CREATE TABLE " & table1 & "(" _ ' Create a new blank table with the specified fields ![]() Vtype = Array("Text", "LongText", "Int(10)", "Float", "Double", "Date", "Time") ' array of commonly used MySQL variable types ' Define variables (not all of the variables will be required for each action) & " OPTION=16427" ' Option 16427 = Convert LongLong to Int: This just helps makes sure that large numeric results get properly interpreted ![]() Password = "userpassword" ' Enter your password hereĬonn.Open "DRIVER=" _ User_id = "userid" ' enter your user ID here Server_name = "127.0.0.1" ' Enter your server name here - if running from a local computer use 127.0.0.1ĭatabase_name = "dbname" ' Enter your database name here See /downloads/connector/odbc/3.51.html or google "MySQL ODBC 3.51 Driver"ĭim sqlstr As String ' SQL to perform various actions ' 1)In VBE you need to go Tools/References and check Microsoft Active X Data Objects 2.x library ' PLEASE DO THE FOLLOWING BEFORE EXECUTING CODE: ' Majority of the original code adapted from Carlmack ' VBA to perform various actions on MySQL tables using VBA
0 Comments
Leave a Reply. |