>*** >USE myRemoteView IN 0 >USE myvfptable IN 0 >SELECT myvfptable >SCAN > SCATTER MEMVAR > INSERT INTO myRemoteView FROM MEMVAR >ENDSCAN >*** >>
* Sample oTransfer = CreateObject("SQLPutData") oTransfer.PutTheData() Define Class SQLPutData As Session DataSession=2 DBPATH = Sys(5)+Curdir()+'myLocalDatabasePath' LocalDBC = 'myLocalDatabase.dbc' SQLDBNAME = "mySQLDatabase" conHandle = .Null. Procedure Init This.conHandle = ; Sqlstringconnect("Driver=SQL server;server=(local);Integrated Security=SSPI") SQLExec(This.conHandle,"use ["+This.SQLDBNAME+"]") Endproc Procedure PutTheData With This .GetDataFrom("[dbo].[mytable]","[field1],[field2],[field3]") SQLDisconnect(.conHandle) endwith endproc Procedure GetDataFrom Lparameters tcSQLName,tcFields Local lcLocalTable, lcLocalFields, lcSQL, lnResult, ix, lcError Local array arrErr[1] lcLocalTable = Justext(Chrtran(tcSQLName,'[]','')) lcLocalFields = Chrtran(tcFields,'[]','') Text to m.lcSQL textmerge noshow insert into <<m.tcSQLName>> SELECT <<m.tcFields>> FROM OPENROWSET('VFPOLEDB', '<<Addbs(this.DBPATH)+this.LocalDBC>>';'';'', 'select <<m.lcLocalFields>> from <<m.lcLocalTable>>') endtext lnResult = SQLExec(this.conHandle, m.lcSQL) If m.lnResult < 0 AError(arrErr) lcError = '' For ix = 1 to Alen(arrErr) lcError = lcError + Transform(arrErr[m.ix]) + Chr(13) EndFor MessageBox(m.lcError) Else ? m.tcSQLName endif Endproc enddefineCetin