I'm writing a routine to upload a .dbf table to a mySql table. Using some code I found on these forums, I'm able to generate a .sql script. What I'm stuck on is executing the .sql script in foxpro. The issue is that I can't get multiple commands to execute from a single script. Only a single command from a single script. What's the trick?
(I've verified that my connection works and I can execute queries to the mysql server.)
And the .sql contents:
Chandler
I ran over my dogma with karma!
(I've verified that my connection works and I can execute queries to the mysql server.)
Code:
lcServer = '***'
lcDatabase = "***"
lcUser = '***'
lcPassWord = '***'
sqlfile = FILETOSTR("r:\imb\imbsetup.sql")
?sqlfile
* run .sql script
GetConnHandle = SQLCONNECT(lcServer,lcUser,lcPassWord)
?GetConnHandle
IF GetConnHandle > -1
= SQLPREPARE(GetConnHandle, sqlfile)
GetQuery = SQLEXEC(GetConnHandle)
IF GetQuery> -1
SELECT SqlResult
COUNT TO lnActiveCards
ENDIF
SQLDISCONNECT(GetConnHandle) && Close the ODBC connection
else
AERROR(laError)
MESSAGEBOX(laError[1,2])
ENDIF
And the .sql contents:
Code:
SET FOREIGN_KEY_CHECKS=0;
USE `production`;
DROP TABLE IF EXISTS `imbserial`;
#
# Structure for the `imbserial` table :
#
CREATE TABLE IF NOT EXISTS `imbserial` (
`ASSIGNID` int (6),
`SNSTART` int (9),
`SNEND` int (9),
`JOBNUM` char (7),
`SHELLNUM` char (20),
`REQDATE` date,
`DATESEED` date
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
#
# Data for the `imbserial` table :
#
INSERT INTO `imbserial` (`ASSIGNID`,`SNSTART`,`SNEND`,`JOBNUM`,`SHELLNUM`,`REQDATE`,`DATESEED`) VALUES
(1 ,100000000,100590489,'0000000','0000000',"20100401","20100401"),
(2 ,100590499,100597571,NULL,'531859A',"20100414","20100401"),
(3 ,100597581,100598330,NULL,'532171A',"20100415","20100401"),
(4 ,100598340,100665249,NULL,'IADTR05A',"20100415","20100401"),
(5 ,100665259,100732168,NULL,'IADTR05A',"20100415","20100401"),
(6 ,100732178,100745725,NULL,'531978A_F',"20100419","20100401"),
(7 ,100745735,100768629,NULL,'532166ABF',"20100419","20100401"),
(8 ,100768639,100781394,NULL,'532166CDE',"20100419","20100401"),
(9 ,100781404,100794951,NULL,'531978A_F',"20100419","20100401"),
(10 ,100794961,100817855,NULL,'532166ABF',"20100419","20100401");
COMMIT;
Chandler
I ran over my dogma with karma!