Using DATAMGR to transfer data between different DBMS's

I had data in an MSACCESS database and I needed the same data in a MYSQL database of the same structure.

Easy enough to do but rather tedious to find out the little syntax differences and to code the insert statements.

So I used datamgr.

Datamgr is a database abstraction tool with a nice straight forward set of functions. Details can be found here

Here is the code I used which made the task very easy in just a few lines of code. All the query syntax and column names are left to datamgr.

<cfset var result = getProfileString(inifile,name,key)>

<!--- Create datamrg objects for each datasource --->
<cfset dmaccess = createobject("component","datamgr.DataMgr_Access").init("mydb_access")>
<cfset dmmysql = createobject("component","datamgr.DataMgr_MYSQL").init("mydb_mysql")>
<!--- Include a udf to convert a query to a structure --->
<cfinclude template="querytostruct.cfm">
<!--- Specify a list of tables to be converted --->
<cfset tablelist = "contact,address,country,order,orderline,product,price">
<cfloop list="#tablelist#" index="thistable">
<!--- Initialise datamgr for the table in question for both datasources --->
<cfset dmaccess.LoadTable(thistable)>
<cfset dmmysql.LoadTable(thistable)>
<cfoutput>#thistable#</cfoutput><br/>
<!--- Read all records in the table from the msaccess datasource --->
    <cfset qmydata = dmaccess.getRecords(thistable)>
<!--- turn query into a array of structures --->
    <cfset arraydata = querytostruct(qmydata)>
<!--- Clear any data in the target table --->
    <cfquery name="clear#thistable#" datasource="mydb_mysql">
     delete from #thistable#
    </cfquery>
    <cfloop from="1" to="#arraylen(arraydata)#" index="i">
separate each row of data as a structure
     <cfset mydata = arraydata[#i#]>
<!--- use datamgr to insert the row of data into mysql --->
     <cfset myprimekey=dmmysql.insertrecord(thistable,mydata)>
    </cfloop>
</cfloop>

<!--- Create datamrg objects for each datasource --->
<cfset dmaccess = createobject("component","datamgr.DataMgr_Access").init("mydb_access")>
<cfset dmmysql = createobject("component","datamgr.DataMgr_MYSQL").init("mydb_mysql")>
<!--- Include a udf to convert a query to a structure --->
<cfinclude template="querytostruct.cfm">
<!--- Specify a list of tables to be converted --->
<cfset tablelist = "contact,address,country,order,orderline,product,price">
<cfloop list="#tablelist#" index="thistable">
<!--- Initialise datamgr for the table in question for both datasources --->
<cfset dmaccess.LoadTable(thistable)>
<cfset dmmysql.LoadTable(thistable)>
<cfoutput>#thistable#</cfoutput><br/>
<!--- Read all records in the table from the msaccess datasource --->
    <cfset qmydata = dmaccess.getRecords(thistable)>
<!--- turn query into a array of structures --->
    <cfset arraydata = querytostruct(qmydata)>
<!--- Clear any data in the target table --->
    <cfquery name="clear#thistable#" datasource="mydb_mysql">
     delete from #thistable#
    </cfquery>
    <cfloop from="1" to="#arraylen(arraydata)#" index="i">
separate each row of data as a structure
     <cfset mydata = arraydata[#i#]>
<!--- use datamgr to insert the row of data into mysql --->
     <cfset myprimekey=dmmysql.insertrecord(thistable,mydata)>
    </cfloop>
</cfloop>

<!--- Create datamrg objects for each datasource --->
<cfset dmaccess = createobject("component","datamgr.DataMgr_Access").init("mydb_access")>
<cfset dmmysql = createobject("component","datamgr.DataMgr_MYSQL").init("mydb_mysql")>
<!--- Include a udf to convert a query to a structure --->
<cfinclude template="querytostruct.cfm">
<!--- Specify a list of tables to be converted --->
<cfset tablelist = "contact,address,country,order,orderline,product,price">
<cfloop list="#tablelist#" index="thistable">
<!--- Initialise datamgr for the table in question for both datasources --->
<cfset dmaccess.LoadTable(thistable)>
<cfset dmmysql.LoadTable(thistable)>
<cfoutput>#thistable#</cfoutput><br/>
<!--- Read all records in the table from the msaccess datasource --->
    <cfset qmydata = dmaccess.getRecords(thistable)>
<!--- turn query into a array of structures --->
    <cfset arraydata = querytostruct(qmydata)>
<!--- Clear any data in the target table --->
    <cfquery name="clear#thistable#" datasource="mydb_mysql">
     delete from #thistable#
    </cfquery>
    <cfloop from="1" to="#arraylen(arraydata)#" index="i">
separate each row of data as a structure
     <cfset mydata = arraydata[#i#]>
<!--- use datamgr to insert the row of data into mysql --->
     <cfset myprimekey=dmmysql.insertrecord(thistable,mydata)>
    </cfloop>
</cfloop>

<!--- Create datamrg objects for each datasource --->
<cfset dmaccess = createobject("component","datamgr.DataMgr_Access").init("mydb_access")>
<cfset dmmysql = createobject("component","datamgr.DataMgr_MYSQL").init("mydb_mysql")>
<!--- Include a udf to convert a query to a structure --->
<cfinclude template="querytostruct.cfm">
<!--- Specify a list of tables to be converted --->
<cfset tablelist = "contact,address,country,order,orderline,product,price">
<cfloop list="#tablelist#" index="thistable">
<!--- Initialise datamgr for the table in question for both datasources --->
<cfset dmaccess.LoadTable(thistable)>
<cfset dmmysql.LoadTable(thistable)>
<cfoutput>#thistable#</cfoutput><br/>
<!--- Read all records in the table from the msaccess datasource --->
    <cfset qmydata = dmaccess.getRecords(thistable)>
<!--- turn query into a array of structures --->
    <cfset arraydata = querytostruct(qmydata)>
<!--- Clear any data in the target table --->
    <cfquery name="clear#thistable#" datasource="mydb_mysql">
     delete from #thistable#
    </cfquery>
    <cfloop from="1" to="#arraylen(arraydata)#" index="i">
separate each row of data as a structure
     <cfset mydata = arraydata[#i#]>
<!--- use datamgr to insert the row of data into mysql --->
     <cfset myprimekey=dmmysql.insertrecord(thistable,mydata)>
    </cfloop>
</cfloop>
<cfif myquery.RecordCount and refind("A1|A2|ZZ|W|X",valuelist(myquery.status))>
<a href="some link">go here</a>
</cfif>
<cfquery name="getContacts" datasource="myContacts">
select name,email
from contacts
</cfquery>
<table>
<tr>
<td>Name</td><td>Email Address</td>
</tr>
<cfoutput query="getContacts">
<tr>
<td>#name#</td><td>#email#</td>
</tr>
</cfoutput>
<tr>
<td colspan="2">You listed:<cfoutput>#getContacts.recordcount#</cfoutput> contacts</td>
</tr>
</table>
<cfset myobj = createobject("java","com.sub.main.entryPoint")>
<cfdump var="#myobj#">
<cfset myobj = createobject("java","entryPoint")>

<!--- Create datamrg objects for each datasource --->
<cfset dmaccess = createobject("component","datamgr.DataMgr_Access").init("mydb_access")>
<cfset dmmysql = createobject("component","datamgr.DataMgr_MYSQL").init("mydb_mysql")>
<!--- Include a udf to convert a query to a structure --->
<cfinclude template="querytostruct.cfm">
<!--- Specify a list of tables to be converted --->
<cfset tablelist = "contact,address,country,order,orderline,product,price">
<cfloop list="#tablelist#" index="thistable">
<!--- Initialise datamgr for the table in question for both datasources --->
<cfset dmaccess.LoadTable(thistable)>
<cfset dmmysql.LoadTable(thistable)>
<cfoutput>#thistable#</cfoutput><br/>
<!--- Read all records in the table from the msaccess datasource --->
    <cfset qmydata = dmaccess.getRecords(thistable)>
<!--- turn query into a array of structures --->
    <cfset arraydata = querytostruct(qmydata)>
<!--- Clear any data in the target table --->
    <cfquery name="clear#thistable#" datasource="mydb_mysql">
     delete from #thistable#
    </cfquery>
    <cfloop from="1" to="#arraylen(arraydata)#" index="i">
separate each row of data as a structure
     <cfset mydata = arraydata[#i#]>
<!--- use datamgr to insert the row of data into mysql --->
     <cfset myprimekey=dmmysql.insertrecord(thistable,mydata)>
    </cfloop>
</cfloop>

<!--- Create datamrg objects for each datasource --->
<cfset dmaccess = createobject("component","datamgr.DataMgr_Access").init("mydb_access")>
<cfset dmmysql = createobject("component","datamgr.DataMgr_MYSQL").init("mydb_mysql")>
<!--- Include a udf to convert a query to a structure --->
<cfinclude template="querytostruct.cfm">
<!--- Specify a list of tables to be converted --->
<cfset tablelist = "contact,address,country,order,orderline,product,price">
<cfloop list="#tablelist#" index="thistable">
<!--- Initialise datamgr for the table in question for both datasources --->
<cfset dmaccess.LoadTable(thistable)>
<cfset dmmysql.LoadTable(thistable)>
<cfoutput>#thistable#</cfoutput><br/>
<!--- Read all records in the table from the msaccess datasource --->
    <cfset qmydata = dmaccess.getRecords(thistable)>
<!--- turn query into a array of structures --->
    <cfset arraydata = querytostruct(qmydata)>
<!--- Clear any data in the target table --->
    <cfquery name="clear#thistable#" datasource="mydb_mysql">
     delete from #thistable#
    </cfquery>
    <cfloop from="1" to="#arraylen(arraydata)#" index="i">
separate each row of data as a structure
     <cfset mydata = arraydata[#i#]>
<!--- use datamgr to insert the row of data into mysql --->
     <cfset myprimekey=dmmysql.insertrecord(thistable,mydata)>
    </cfloop>
</cfloop>

<!--- Create datamrg objects for each datasource --->
<cfset dmaccess = createobject("component","datamgr.DataMgr_Access").init("mydb_access")>
<cfset dmmysql = createobject("component","datamgr.DataMgr_MYSQL").init("mydb_mysql")>
<!--- Include a udf to convert a query to a structure --->
<cfinclude template="querytostruct.cfm">
<!--- Specify a list of tables to be converted --->
<cfset tablelist = "contact,address,country,order,orderline,product,price">
<cfloop list="#tablelist#" index="thistable">
<!--- Initialise datamgr for the table in question for both datasources --->
<cfset dmaccess.LoadTable(thistable)>
<cfset dmmysql.LoadTable(thistable)>
<cfoutput>#thistable#</cfoutput><br/>
<!--- Read all records in the table from the msaccess datasource --->
    <cfset qmydata = dmaccess.getRecords(thistable)>
<!--- turn query into a array of structures --->
    <cfset arraydata = querytostruct(qmydata)>
<!--- Clear any data in the target table --->
    <cfquery name="clear#thistable#" datasource="mydb_mysql">
     delete from #thistable#
    </cfquery>
    <cfloop from="1" to="#arraylen(arraydata)#" index="i">
separate each row of data as a structure
     <cfset mydata = arraydata[#i#]>
<!--- use datamgr to insert the row of data into mysql --->
     <cfset myprimekey=dmmysql.insertrecord(thistable,mydata)>
    </cfloop>
</cfloop>

<!--- Create datamrg objects for each datasource --->
<cfset dmaccess = createobject("component","datamgr.DataMgr_Access").init("mydb_access")>
<cfset dmmysql = createobject("component","datamgr.DataMgr_MYSQL").init("mydb_mysql")>
<!--- Include a udf to convert a query to a structure --->
<cfinclude template="querytostruct.cfm">
<!--- Specify a list of tables to be converted --->
<cfset tablelist = "contact,address,country,order,orderline,product,price">
<cfloop list="#tablelist#" index="thistable">
<!--- Initialise datamgr for the table in question for both datasources --->
<cfset dmaccess.LoadTable(thistable)>
<cfset dmmysql.LoadTable(thistable)>
<cfoutput>#thistable#</cfoutput><br/>
<!--- Read all records in the table from the msaccess datasource --->
    <cfset qmydata = dmaccess.getRecords(thistable)>
<!--- turn query into a array of structures --->
    <cfset arraydata = querytostruct(qmydata)>
<!--- Clear any data in the target table --->
    <cfquery name="clear#thistable#" datasource="mydb_mysql">
     delete from #thistable#
    </cfquery>
    <cfloop from="1" to="#arraylen(arraydata)#" index="i">
separate each row of data as a structure
     <cfset mydata = arraydata[#i#]>
<!--- use datamgr to insert the row of data into mysql --->
     <cfset myprimekey=dmmysql.insertrecord(thistable,mydata)>
    </cfloop>
</cfloop>
javacast("null","")
<cfset var result = getProfileString(inifile,name,key)>
javacast("null","")
<cfset var result = getProfileString(inifile,name,key)>

<!--- Create datamrg objects for each datasource --->
<cfset dmaccess = createobject("component","datamgr.DataMgr_Access").init("mydb_access")>
<cfset dmmysql = createobject("component","datamgr.DataMgr_MYSQL").init("mydb_mysql")>
<!--- Include a udf to convert a query to a structure --->
<cfinclude template="querytostruct.cfm">
<!--- Specify a list of tables to be converted --->
<cfset tablelist = "contact,address,country,order,orderline,product,price">
<cfloop list="#tablelist#" index="thistable">
<!--- Initialise datamgr for the table in question for both datasources --->
<cfset dmaccess.LoadTable(thistable)>
<cfset dmmysql.LoadTable(thistable)>
<cfoutput>#thistable#</cfoutput><br/>
<!--- Read all records in the table from the msaccess datasource --->
    <cfset qmydata = dmaccess.getRecords(thistable)>
<!--- turn query into a array of structures --->
    <cfset arraydata = querytostruct(qmydata)>
<!--- Clear any data in the target table --->
    <cfquery name="clear#thistable#" datasource="mydb_mysql">
     delete from #thistable#
    </cfquery>
    <cfloop from="1" to="#arraylen(arraydata)#" index="i">
separate each row of data as a structure
     <cfset mydata = arraydata[#i#]>
<!--- use datamgr to insert the row of data into mysql --->
     <cfset myprimekey=dmmysql.insertrecord(thistable,mydata)>
    </cfloop>
</cfloop>

<!--- Create datamrg objects for each datasource --->
<cfset dmaccess = createobject("component","datamgr.DataMgr_Access").init("mydb_access")>
<cfset dmmysql = createobject("component","datamgr.DataMgr_MYSQL").init("mydb_mysql")>
<!--- Include a udf to convert a query to a structure --->
<cfinclude template="querytostruct.cfm">
<!--- Specify a list of tables to be converted --->
<cfset tablelist = "contact,address,country,order,orderline,product,price">
<cfloop list="#tablelist#" index="thistable">
<!--- Initialise datamgr for the table in question for both datasources --->
<cfset dmaccess.LoadTable(thistable)>
<cfset dmmysql.LoadTable(thistable)>
<cfoutput>#thistable#</cfoutput><br/>
<!--- Read all records in the table from the msaccess datasource --->
    <cfset qmydata = dmaccess.getRecords(thistable)>
<!--- turn query into a array of structures --->
    <cfset arraydata = querytostruct(qmydata)>
<!--- Clear any data in the target table --->
    <cfquery name="clear#thistable#" datasource="mydb_mysql">
     delete from #thistable#
    </cfquery>
    <cfloop from="1" to="#arraylen(arraydata)#" index="i">
separate each row of data as a structure
     <cfset mydata = arraydata[#i#]>
<!--- use datamgr to insert the row of data into mysql --->
     <cfset myprimekey=dmmysql.insertrecord(thistable,mydata)>
    </cfloop>
</cfloop>

<!--- Create datamrg objects for each datasource --->
<cfset dmaccess = createobject("component","datamgr.DataMgr_Access").init("mydb_access")>
<cfset dmmysql = createobject("component","datamgr.DataMgr_MYSQL").init("mydb_mysql")>
<!--- Include a udf to convert a query to a structure --->
<cfinclude template="querytostruct.cfm">
<!--- Specify a list of tables to be converted --->
<cfset tablelist = "contact,address,country,order,orderline,product,price">
<cfloop list="#tablelist#" index="thistable">
<!--- Initialise datamgr for the table in question for both datasources --->
<cfset dmaccess.LoadTable(thistable)>
<cfset dmmysql.LoadTable(thistable)>
<cfoutput>#thistable#</cfoutput><br/>
<!--- Read all records in the table from the msaccess datasource --->
    <cfset qmydata = dmaccess.getRecords(thistable)>
<!--- turn query into a array of structures --->
    <cfset arraydata = querytostruct(qmydata)>
<!--- Clear any data in the target table --->
    <cfquery name="clear#thistable#" datasource="mydb_mysql">
     delete from #thistable#
    </cfquery>
    <cfloop from="1" to="#arraylen(arraydata)#" index="i">
separate each row of data as a structure
     <cfset mydata = arraydata[#i#]>
<!--- use datamgr to insert the row of data into mysql --->
     <cfset myprimekey=dmmysql.insertrecord(thistable,mydata)>
    </cfloop>
</cfloop>

<!--- Create datamrg objects for each datasource --->
<cfset dmaccess = createobject("component","datamgr.DataMgr_Access").init("mydb_access")>
<cfset dmmysql = createobject("component","datamgr.DataMgr_MYSQL").init("mydb_mysql")>
<!--- Include a udf to convert a query to a structure --->
<cfinclude template="querytostruct.cfm">
<!--- Specify a list of tables to be converted --->
<cfset tablelist = "contact,address,country,order,orderline,product,price">
<cfloop list="#tablelist#" index="thistable">
<!--- Initialise datamgr for the table in question for both datasources --->
<cfset dmaccess.LoadTable(thistable)>
<cfset dmmysql.LoadTable(thistable)>
<cfoutput>#thistable#</cfoutput><br/>
<!--- Read all records in the table from the msaccess datasource --->
    <cfset qmydata = dmaccess.getRecords(thistable)>
<!--- turn query into a array of structures --->
    <cfset arraydata = querytostruct(qmydata)>
<!--- Clear any data in the target table --->
    <cfquery name="clear#thistable#" datasource="mydb_mysql">
     delete from #thistable#
    </cfquery>
    <cfloop from="1" to="#arraylen(arraydata)#" index="i">
separate each row of data as a structure
     <cfset mydata = arraydata[#i#]>
<!--- use datamgr to insert the row of data into mysql --->
     <cfset myprimekey=dmmysql.insertrecord(thistable,mydata)>
    </cfloop>
</cfloop>
javacast("null","")
<cfset var result = getProfileString(inifile,name,key)>

<!--- Create datamrg objects for each datasource --->
<cfset dmaccess = createobject("component","datamgr.DataMgr_Access").init("mydb_access")>
<cfset dmmysql = createobject("component","datamgr.DataMgr_MYSQL").init("mydb_mysql")>
<!--- Include a udf to convert a query to a structure --->
<cfinclude template="querytostruct.cfm">
<!--- Specify a list of tables to be converted --->
<cfset tablelist = "contact,address,country,order,orderline,product,price">
<cfloop list="#tablelist#" index="thistable">
<!--- Initialise datamgr for the table in question for both datasources --->
<cfset dmaccess.LoadTable(thistable)>
<cfset dmmysql.LoadTable(thistable)>
<cfoutput>#thistable#</cfoutput><br/>
<!--- Read all records in the table from the msaccess datasource --->
    <cfset qmydata = dmaccess.getRecords(thistable)>
<!--- turn query into a array of structures --->
    <cfset arraydata = querytostruct(qmydata)>
<!--- Clear any data in the target table --->
    <cfquery name="clear#thistable#" datasource="mydb_mysql">
     delete from #thistable#
    </cfquery>
    <cfloop from="1" to="#arraylen(arraydata)#" index="i">
separate each row of data as a structure
     <cfset mydata = arraydata[#i#]>
<!--- use datamgr to insert the row of data into mysql --->
     <cfset myprimekey=dmmysql.insertrecord(thistable,mydata)>
    </cfloop>
</cfloop>

<!--- Create datamrg objects for each datasource --->
<cfset dmaccess = createobject("component","datamgr.DataMgr_Access").init("mydb_access")>
<cfset dmmysql = createobject("component","datamgr.DataMgr_MYSQL").init("mydb_mysql")>
<!--- Include a udf to convert a query to a structure --->
<cfinclude template="querytostruct.cfm">
<!--- Specify a list of tables to be converted --->
<cfset tablelist = "contact,address,country,order,orderline,product,price">
<cfloop list="#tablelist#" index="thistable">
<!--- Initialise datamgr for the table in question for both datasources --->
<cfset dmaccess.LoadTable(thistable)>
<cfset dmmysql.LoadTable(thistable)>
<cfoutput>#thistable#</cfoutput><br/>
<!--- Read all records in the table from the msaccess datasource --->
    <cfset qmydata = dmaccess.getRecords(thistable)>
<!--- turn query into a array of structures --->
    <cfset arraydata = querytostruct(qmydata)>
<!--- Clear any data in the target table --->
    <cfquery name="clear#thistable#" datasource="mydb_mysql">
     delete from #thistable#
    </cfquery>
    <cfloop from="1" to="#arraylen(arraydata)#" index="i">
separate each row of data as a structure
     <cfset mydata = arraydata[#i#]>
<!--- use datamgr to insert the row of data into mysql --->
     <cfset myprimekey=dmmysql.insertrecord(thistable,mydata)>
    </cfloop>
</cfloop>

<!--- Create datamrg objects for each datasource --->
<cfset dmaccess = createobject("component","datamgr.DataMgr_Access").init("mydb_access")>
<cfset dmmysql = createobject("component","datamgr.DataMgr_MYSQL").init("mydb_mysql")>
<!--- Include a udf to convert a query to a structure --->
<cfinclude template="querytostruct.cfm">
<!--- Specify a list of tables to be converted --->
<cfset tablelist = "contact,address,country,order,orderline,product,price">
<cfloop list="#tablelist#" index="thistable">
<!--- Initialise datamgr for the table in question for both datasources --->
<cfset dmaccess.LoadTable(thistable)>
<cfset dmmysql.LoadTable(thistable)>
<cfoutput>#thistable#</cfoutput><br/>
<!--- Read all records in the table from the msaccess datasource --->
    <cfset qmydata = dmaccess.getRecords(thistable)>
<!--- turn query into a array of structures --->
    <cfset arraydata = querytostruct(qmydata)>
<!--- Clear any data in the target table --->
    <cfquery name="clear#thistable#" datasource="mydb_mysql">
     delete from #thistable#
    </cfquery>
    <cfloop from="1" to="#arraylen(arraydata)#" index="i">
separate each row of data as a structure
     <cfset mydata = arraydata[#i#]>
<!--- use datamgr to insert the row of data into mysql --->
     <cfset myprimekey=dmmysql.insertrecord(thistable,mydata)>
    </cfloop>
</cfloop>
javacast("null","")
javacast("null","")

<!--- Create datamrg objects for each datasource --->
<cfset dmaccess = createobject("component","datamgr.DataMgr_Access").init("mydb_access")>
<cfset dmmysql = createobject("component","datamgr.DataMgr_MYSQL").init("mydb_mysql")>
<!--- Include a udf to convert a query to a structure --->
<cfinclude template="querytostruct.cfm">
<!--- Specify a list of tables to be converted --->
<cfset tablelist = "contact,address,country,order,orderline,product,price">
<cfloop list="#tablelist#" index="thistable">
<!--- Initialise datamgr for the table in question for both datasources --->
<cfset dmaccess.LoadTable(thistable)>
<cfset dmmysql.LoadTable(thistable)>
<cfoutput>#thistable#</cfoutput><br/>
<!--- Read all records in the table from the msaccess datasource --->
    <cfset qmydata = dmaccess.getRecords(thistable)>
<!--- turn query into a array of structures --->
    <cfset arraydata = querytostruct(qmydata)>
<!--- Clear any data in the target table --->
    <cfquery name="clear#thistable#" datasource="mydb_mysql">
     delete from #thistable#
    </cfquery>
    <cfloop from="1" to="#arraylen(arraydata)#" index="i">
separate each row of data as a structure
     <cfset mydata = arraydata[#i#]>
<!--- use datamgr to insert the row of data into mysql --->
     <cfset myprimekey=dmmysql.insertrecord(thistable,mydata)>
    </cfloop>
</cfloop>

<!--- Create datamrg objects for each datasource --->
<cfset dmaccess = createobject("component","datamgr.DataMgr_Access").init("mydb_access")>
<cfset dmmysql = createobject("component","datamgr.DataMgr_MYSQL").init("mydb_mysql")>
<!--- Include a udf to convert a query to a structure --->
<cfinclude template="querytostruct.cfm">
<!--- Specify a list of tables to be converted --->
<cfset tablelist = "contact,address,country,order,orderline,product,price">
<cfloop list="#tablelist#" index="thistable">
<!--- Initialise datamgr for the table in question for both datasources --->
<cfset dmaccess.LoadTable(thistable)>
<cfset dmmysql.LoadTable(thistable)>
<cfoutput>#thistable#</cfoutput><br/>
<!--- Read all records in the table from the msaccess datasource --->
    <cfset qmydata = dmaccess.getRecords(thistable)>
<!--- turn query into a array of structures --->
    <cfset arraydata = querytostruct(qmydata)>
<!--- Clear any data in the target table --->
    <cfquery name="clear#thistable#" datasource="mydb_mysql">
     delete from #thistable#
    </cfquery>
    <cfloop from="1" to="#arraylen(arraydata)#" index="i">
separate each row of data as a structure
     <cfset mydata = arraydata[#i#]>
<!--- use datamgr to insert the row of data into mysql --->
     <cfset myprimekey=dmmysql.insertrecord(thistable,mydata)>
    </cfloop>
</cfloop>

<!--- Create datamrg objects for each datasource --->
<cfset dmaccess = createobject("component","datamgr.DataMgr_Access").init("mydb_access")>
<cfset dmmysql = createobject("component","datamgr.DataMgr_MYSQL").init("mydb_mysql")>
<!--- Include a udf to convert a query to a structure --->
<cfinclude template="querytostruct.cfm">
<!--- Specify a list of tables to be converted --->
<cfset tablelist = "contact,address,country,order,orderline,product,price">
<cfloop list="#tablelist#" index="thistable">
<!--- Initialise datamgr for the table in question for both datasources --->
<cfset dmaccess.LoadTable(thistable)>
<cfset dmmysql.LoadTable(thistable)>
<cfoutput>#thistable#</cfoutput><br/>
<!--- Read all records in the table from the msaccess datasource --->
    <cfset qmydata = dmaccess.getRecords(thistable)>
<!--- turn query into a array of structures --->
    <cfset arraydata = querytostruct(qmydata)>
<!--- Clear any data in the target table --->
    <cfquery name="clear#thistable#" datasource="mydb_mysql">
     delete from #thistable#
    </cfquery>
    <cfloop from="1" to="#arraylen(arraydata)#" index="i">
separate each row of data as a structure
     <cfset mydata = arraydata[#i#]>
<!--- use datamgr to insert the row of data into mysql --->
     <cfset myprimekey=dmmysql.insertrecord(thistable,mydata)>
    </cfloop>
</cfloop>

<!--- Create datamrg objects for each datasource --->
<cfset dmaccess = createobject("component","datamgr.DataMgr_Access").init("mydb_access")>
<cfset dmmysql = createobject("component","datamgr.DataMgr_MYSQL").init("mydb_mysql")>
<!--- Include a udf to convert a query to a structure --->
<cfinclude template="querytostruct.cfm">
<!--- Specify a list of tables to be converted --->
<cfset tablelist = "contact,address,country,order,orderline,product,price">
<cfloop list="#tablelist#" index="thistable">
<!--- Initialise datamgr for the table in question for both datasources --->
<cfset dmaccess.LoadTable(thistable)>
<cfset dmmysql.LoadTable(thistable)>
<cfoutput>#thistable#</cfoutput><br/>
<!--- Read all records in the table from the msaccess datasource --->
    <cfset qmydata = dmaccess.getRecords(thistable)>
<!--- turn query into a array of structures --->
    <cfset arraydata = querytostruct(qmydata)>
<!--- Clear any data in the target table --->
    <cfquery name="clear#thistable#" datasource="mydb_mysql">
     delete from #thistable#
    </cfquery>
    <cfloop from="1" to="#arraylen(arraydata)#" index="i">
separate each row of data as a structure
     <cfset mydata = arraydata[#i#]>
<!--- use datamgr to insert the row of data into mysql --->
     <cfset myprimekey=dmmysql.insertrecord(thistable,mydata)>
    </cfloop>
</cfloop>

<!--- Create datamrg objects for each datasource --->
<cfset dmaccess = createobject("component","datamgr.DataMgr_Access").init("mydb_access")>
<cfset dmmysql = createobject("component","datamgr.DataMgr_MYSQL").init("mydb_mysql")>
<!--- Include a udf to convert a query to a structure --->
<cfinclude template="querytostruct.cfm">
<!--- Specify a list of tables to be converted --->
<cfset tablelist = "contact,address,country,order,orderline,product,price">
<cfloop list="#tablelist#" index="thistable">
<!--- Initialise datamgr for the table in question for both datasources --->
<cfset dmaccess.LoadTable(thistable)>
<cfset dmmysql.LoadTable(thistable)>
<cfoutput>#thistable#</cfoutput><br/>
<!--- Read all records in the table from the msaccess datasource --->
    <cfset qmydata = dmaccess.getRecords(thistable)>
<!--- turn query into a array of structures --->
    <cfset arraydata = querytostruct(qmydata)>
<!--- Clear any data in the target table --->
    <cfquery name="clear#thistable#" datasource="mydb_mysql">
     delete from #thistable#
    </cfquery>
    <cfloop from="1" to="#arraylen(arraydata)#" index="i">
separate each row of data as a structure
     <cfset mydata = arraydata[#i#]>
<!--- use datamgr to insert the row of data into mysql --->
     <cfset myprimekey=dmmysql.insertrecord(thistable,mydata)>
    </cfloop>
</cfloop>


Thanks to Steve Bryant for the datamgr.cfc.

Comments
BlogCFC was created by Raymond Camden. This blog is running version 5.9.003. Contact Blog Owner