I can connect to each DB, view the data and display the data. But, I cannot figure out how to INSERT or UPDATE the data from the MSSQL to the MySQL. So, either INSERT a non existing record or UPDATE an existing record.
I am only dealing with one table that has about twelve fields.
I have the following concept:
<?php
//connect to the MSSQL server and select database
//connect to the MySQL server, select database
//query to get required fields from MSSQL DB
//run the query on the database
//loop to get each row from the MSSQL DB
//connect to MySQL server, select db and UPDATE or INSERT row
?>
Also, this is the code that I am trying to utilize:
Code: Select all
<?php
while (!$rs->EOF) //carry on looping through while there are records
{
$counter++;//For testing
$gen_name = $rs["storename"];
$gen_add = $rs["address"];
$gen_city = $rs["city"];
$gen_state = $rs["state"];
$gen_zip = $rs["zip"];
//connect to mysql server, select db and insert row
mysql_connect($myhostname,$myusername,$mypassword) or die ("MySQL Database connection failed during loop.");
mysql_select_db($mydbname) or die ("MySQL DB unavailable during loop.");
//test display
echo $counter,"MySQL looping1 - name=$gen_name<br />";
//test display
$sql_in = ("INSERT INTO locations (storename,address,city,state,zip)
VALUES ('$gen_name','$gen_add','$gen_city','$gen_state','$gen_zip')");
mysql_query($sql_in);
//create an instance of the ADO connection object
$conn = new COM ("ADODB.Connection")
or die("Cannot start ADO");
//connect to MSSQL server
$connStr = "PROVIDER=SQLOLEDB;SERVER=".$msServer.";UID=".$msUser.";PWD=".$msPass.";DATABASE=".$msDB;
$conn->open($connStr); //Open the connection to the database
$rs->MoveNext(); //move on to the next record
}
?>Thanks for any help or advice!