本網頁以打造無障礙閱讀為目標,可以用任何瀏覽器來觀看本網頁
| 操作 | VFP基本語法 | VFP的SQL語法 |
|---|---|---|
| 瀏覽資料庫 | use emp browse |
select * from emp |
| 設定條件瀏覽資料庫 | use emp browse for salary>50000 |
select * from emp where salary>50000 |
| 建立資料庫 | create emp | CREATE TABLE emp (id c(6)) |
| 修改紀錄 | use emp replace salary with 60000 for name="Peter" |
update emp set salary=60000 where name="Peter" |
| 新增紀錄 | use emp append blank replace name with "Tom" |
INSERT INTO emp (name) values ("Tom") |
| 刪除紀錄 | use emp delete for name="Tom" |
delete from emp where name="Tom" |
就微軟的DCOM技術而言,可供重複使用的control必須先在 Windows 中註冊才能使用,註冊control一般來說有5種方法,它們有各自的優點,運用範圍也不同。
利用微軟系統提供的regsvr32.exe可註冊指定的元件,若成功註冊,會跳出一視窗「DllRegisterServer in xxx.ocx succeeded」,若解除成功則會跳出「UnDllRegisterServer ...........」代表成功的執行了元件內部的註冊函數DllRegisterServer或解註冊函數UnDllRegisterServer。
*********************
* SQL Server 連結設定
*********************
lcUserName="sa"
lcServerName="127.0.0.1"
lcUserPass="123456"
lcDBName="master"
ConnectionHandle=SQLSTRINGCONNECT([DRIVER=SQL Server;SERVER=]+lcServerName+[;DATABASE=]+lcDBName+[;UID=]+lcUserName+[;PWD=]+lcUserPass )
if ConnectionHandle <= 0
messagebox('無法連接至 SQL SERVER ('+ lcServerName +')',16,"SQL Connect Error" )
quit
endif
*********************
* 執行 SQL
*********************
SQLCOMMAND="select a.uname, a.upass, a.udep ,s.address ;
from admin a, schools s where a.uname=s.scode and s.scode = '034729'"
mret=sqlexec(ConnectionHandle,SQLCOMMAND)
if mret<=0
messagebox('sql敘述執行失敗' )
quit
endif
*********************
* 取回後處理
*********************
copy to tmp\tmp.dbf
browse
*********************
* 離線與關閉
*********************
mret=SQLDISCONN(ConnectionHandle)
if mret<=0
messagebox('離線失敗' )
quit
endif
Exl_file = GETFILE('XLS', '選擇或取消', '選擇', 0, '請選擇要讀入的Excel檔')
DO CASE
CASE EMPTY(Exl_file)
Messagebox("並未選擇要讀入的Excel檔",1+32,"訊息視窗")
QUIT
OTHERWISE
? "你選擇要讀入的Excel檔是 "+Exl_file
ENDCASE
import from &Exl_file Type xl8
browse
use Student
copy to stu_info type XL5
use Student
copy to stu_info type CSV
use Student
copy to stu_info type DELIMITED
use Student
copy to stu_info type SDF
counter=adir(testarray,'*.txt')
dimension myarray(counter,5)
counter=adir(myarray,'*.txt')
for i =1 to counter
filename=myarray(i,1)
? filename
next
ON ERROR DO errhand WITH ERROR(), MESSAGE(), MESSAGE(1), PROGRAM( ),LINENO( ) && Trap OLE & other errors.
******************************************
* 說 明:錯誤處理程式
******************************************
PROCEDURE errhand
PARAMETER merror, mess, mess1, mprog, mlineno
CLEAR
IF merror=1426
mlineno=LTRIM(STR(LINENO()))
merror=LTRIM(STR(merror))
MESSAGEBOX("發生了一個OLE的錯誤,例如:呼叫的OLE程式重複開啟了檔案 "+CHR(13)+;
"Usually this is caused by quitting Word or canceling out of a dialog box in Word. "+CHR(13)+;
"錯誤訊息為:"+mess)
ELSE
mlineno=LTRIM(STR(LINENO()))
merror=LTRIM(STR(merror))
MESSAGEBOX("發生錯誤在程式第"+mlineno+"行"+CHR(13)+;
"錯誤訊息為:"+mess+" 錯誤代碼為"+merror)
ENDIF
ON ERROR
quit
RETURN
cCurrentProcedure = SYS(16,1)
nPathStart = AT(":",cCurrentProcedure)- 1
nLenOfPath = RAT("\", cCurrentProcedure) - (nPathStart) + 1
SET DEFAULT TO (SUBSTR(cCurrentProcedure, nPathStart, nLenofPath))
gcXLS=GETFILE('XLS', '選擇或取消', '選擇', 0, '請選擇要處理的 Excel 檔')
DO CASE
CASE EMPTY(gcXLS)
Messagebox("並未選擇要處理的 Excel 檔",1+32,"訊息視窗")
QUIT
OTHERWISE
? "你選擇要處理的 Excel 檔是 "+gcXLS
ENDCASE
IF !DIRECTORY("tmp")
MKDIR tmp
ENDIF
主 網 站:http://peterju.notlong.com (目前轉址至 http://irw.ncut.edu.tw/peterju/)