Article ID: 191413
Article Last Modified on 7/13/2004
LOCAL lcConnStr,lcSQL,oConnection,rs
lcConnStr="DSN=Visual FoxPro Database;UID=;PWD=;"+ ;
"SourceDB="+HOME(2)+"data\Testdata.dbc;"+ ;
"SourceType=DBC;Exclusive=No;BackgroundFetch=No;Collate=Machine;"
lcSQL="select * FROM orders.dbf WHERE To_Region='WA'"
oConnection=CREATEOBJECT("ADODB.Connection")
oConnection.open(lcConnStr)
rs=oConnection.execute(lcSQL)
rs.close
rs.cursorType=3 && 3=ADOPENSTATIC
rs.cursorLocation=2 && 2=ADUSESERVER
rs.lockType=3 && 3=ADLOCKOPTIMISTIC
rs.open
MESSAGEBOX("Record 1 (before):"+CHR(13)+CHR(13)+ ;
"City: "+rs.fields("To_City").value+CHR(13)+ ;
"Order Amount: "+TRANSFORM(rs.fields("Order_Amt").value))
rs.fields("To_City").value="Bellevue"
rs.fields("Order_Amt").value=rs.fields("Order_Amt").value+1
rs.updateBatch
rs.close
rs.open
MESSAGEBOX("Record 1 (after):"+CHR(13)+CHR(13)+ ;
"City: "+rs.fields("To_City").value+CHR(13)+ ;
"Order Amount: "+TRANSFORM(rs.fields("Order_Amt").value))
rs.close
oConnection.close
RETURN
The results of the preceding program code can be checked by issuing the following commands from the Visual FoxPro Command window:
USE HOME(2)+"data\Orders"
BROWSE FOR To_Region="WA"
Look at the Order_amt column for the first record in the Browse window.
LOCAL lcConnStr,lcSQL,oConnection,rs,lcFileName
lcFileName=LOWER(SYS(2023))+"\orders.rs"
lcConnStr="Driver={Microsoft Visual FoxPro Driver};UID=;PWD=;"+ ;
"SourceDB="+HOME(2)+"data\Testdata.dbc;"+ ;
"SourceType=DBC;Exclusive=No;BackgroundFetch=No;Collate=Machine;"
lcSQL="select * FROM orders.dbf WHERE To_Region='WA'"
oConnection=CREATEOBJECT("ADODB.Connection")
oConnection.open(lcConnStr)
rs=oConnection.execute(lcSQL)
rs.close
rs.cursorType=3 && 3=ADOPENSTATIC
rs.cursorLocation=3 && 3=ADUSECLIENT
rs.lockType=3 && 3=ADLOCKOPTIMISTIC
rs.open
ERASE (lcFileName)
rs.save(lcFileName)
rs.close
oConnection.close
RETURN
Look for Orders.rs in the Temp directory after running this code. The
SYS(2023) function returns the path to where Visual FoxPro stores its
temporary files which is the Windows' temporary directory by default.
186086 How To Get a File DSN in the Connection Designer
Additional query words: PGFEST600 kbVFp600 kbADO kbADO200
Keywords: kbhowto kbdatabase KB191413