>I am looking for some sample code showing ADO being used to send data back and forth between VFP and SQL Server.
>
>Thanks v. much in advance!
Following is simplistic code for reading from VFP table and writing to SQL server table:
Local cCnString, oConn, oRS, cSql, cText
oConn = CreateObject("ADODB.connection")
oRS = CreateObject("ADODB.Recordset")
cCnString= "Driver=Microsoft Visual FoxPro Driver; " + ;
"SourceType=DBf;SourceDB=c:\test;BackgroundFetch=No;"
oConn.Open(cCnString)
oRS.cursortype = 3
oRS.cursorlocation = 3
oRS.locktype = 3
oRS.Open("select * from customer",oConn)
oRS.ActiveConnection = .null.
Do while oConn.State=1
oConn.Close
Enddo
cCnString= "Provider=SQLOLEDB.1;"+;
"Integrated Security=SSPI;"+;
"Persist Security Info=False;"+;
"Initial Catalog=mySQLTable;"+;
"Data Source=mySQLServer"
oConn.Open(cCnString)
cText = "Insert Into customer Values ("
Do While Not oRS.EOF
cSql = cText + Transform(oRS.Fields("custid").Value) + ","
cSql = cSql + "'" + oRS.Fields("name").Value + "')"
oConn.Execute(cSql,,128)
oRS.MoveNext
EndDo
oRS.Close
oConn.Close