vfp远程视图与spt应用详解 - 百度文库

cnn=SQLCONNECT(\ SQLEXEC(cnn,\orderid,productid,unitprice,quantity,discount details]\SELECT mycursor

CURSORSETPROP(\

CURSORSETPROP(\

CURSORSETPROP(\CURSORSETPROP(\

[order

details].orderid,unitprice

[order

details].unitprice,quantity [order details].quantity,discount [order details].discount\CURSORSETPROP(\

һOrder Details

ע⡰TablesԵдSQL Serverִոı÷ںŷָTablesָԴԱã[order details]롣

ע⡰KeyFieldListԵдorder detailsؼһϹؼ֣orderidproductidɣҪһ롣

һҪԡWhereType

趨Ϊɸ¹󣬻һҪû趨WhereTypeWhere־ݣ

CURSORSETPROP(\ݹؼ

CURSORSETPROP(\ݹؼ֣ɸֶ CURSORSETPROP(\ݹؼ+Ѹֶ CURSORSETPROP(\ݹؼ֣ʱ

ϸݴҿԲοԶͼ½ڣѾúܶˡ

from [order

ġvfpsql serverClient/ServerӦó(Զͼ)(1)

-

ǡ Visual FoxPro SQL Server Client/Server Ӧóϵеһ֣ԶͼӦǿƪ½ڣǷ:Ϊվ׼̫ԵĶΪ˻һìܣǾѡԶͼд

е ADO ̥ Visual FoxProʵʹ߸ɫԲҪС Visual FoxPro Զݴϵǿ󣡶߿ԲοվġMicrosoft Visual FoxPro Ա ADO š롶Visual FoxPro ̸

ϣͨصʽɡ Visual FoxPro SQL Server Client/Server ӦóһģdzϣõĽ顣

˵ǰ

ڱ֮ڸϳģ˼ܣѡ SQL Server ݿʱһNorthwind ݿоֶַΣУʹ nVarchar ͣVisual FoxPro Դֵ֧IJãԭվϿʾԴǿ SQL Server Enterprise Manager айֶεĵʹ nVarchar Ϊ Varcharҽ Customers е CustomerID Phoneֶεͱ仯ɡͬģǿ԰ Employees Notes ֶͱΪ text

ҵĴ

Visual FoxPro ͼȻෳ˵ԶͼIJرӵԶͼֺܻ֧ܲĶʵʱ벻ҪߡVisual FoxPro ԶͼĹܷdzǿģ󵽹߳ͼܺܺõ֧֣

ǰ

Visual FoxPro Ϊ Client/Server ܵӦṩõĽԶͼ(Remote Views) SPT(SQL pass through)ȻVisual FoxProǿʹԶӵķ ADOЩӣԶͼĺôԷdzVisual FoxProÿؼ󶨡ÿһԶͼһ洢Visual FoxProݿDBCĶһSQL-SELECT䡣ԶͼͨODBCOpen Database Connectivity)칹ݿͨѶ

ȻĵʵʹSQL Server Ϊݿ⣬ͬʹԴΪݿ⣬ OracleIBM DB2Informix,Sybase,Microsoft Access,Excel,Visual FoxProԼʹԶͼԶݾVisual FoxProһ㣬ǽһΰ󹤾ߵijӦá

-Connections

ʹԶͼԶݵĵһǽԶԴͨѶкüַɹѡעЩʹ ODBC Զӡ

һdz򵥵Զͼǣȡ Northwind ݿ Customers ļ¼Զͼ Vcustomers С

CREATE SQL VIEW Vcustomers ; REMOTE CONNECTION Northwind ; AS SELECT * From Customers

*ȱ䣬Ϊӻûн

ĵڶǸVisual FoxProʹ Northwind SQL Server ͨѶʱVisual FoxProطѰӣ

ǰ ݿDBCв鿴Ƿݿ⡰Ӷ󡱡Northwind֮߳Ϊ DSN Ӷ

ûз֣Visual FoxProڿͻ OCBC Data Source Names(DSNs)в鿴Ƿ Northwind֮߳Ϊ DSN ӡ

DSNs

ӵ졢ķǽDSNsڿд ODBC ͼ1

ͼ 1. ODBC Data Source Administrator

ǷDSN :

ûDSNϵͳDSNļDSNûֻԽûЧƩ Administrator ݵ¼ϵͳһûDSNô Administrator ¼ϵͳ㲻ʹһDSNϵͳԵǰûûЧʲôݵ¼ϵͳļDSNʵһDSNΪ׺ıļ Visual FoxPro ĽǶȣ߰ DSN ֳࣺ

û͡ϵͳ DSNԵΪΪԶͼʹãҲΪ DSN Ӷ󡱵Ļ DSN Ӷûͻϵͳ DSN

ļ DSNԵΪΪԶͼʹãΪơַӶṩϣַӶ󡱲ļ DSN

Ƚһϵͳ DSN

ODBC Data Source Administrator ѡ System DSNҳAddѡ SQL Server 򣬰ɡťͼ2

ͼ 2. 趨 DSN Ƽ

ѡ񡰣local)עϵͳĿ޷ӽ˳Ļͼ3Ļ棬Ҫѡû֤ʽѡ SQL Server Windows ֤ʽ¼SQL ServerûsaΪա

ͼ 3. 趨 DSN ĵ¼Ϣ

˳4ĻϣһѡҪرע⣬ѡĿݿ⡣ǵȻѡNorthwind

ͼ 4. 趨 DSN ĵ¼ݿ

ϻͲ˵ˣһЩ˳СNorthwindSystem DSN ͽˡ

Visual FoxProн䣺

CREATE DATABASE Northwind

*ݿ洢ݿ CREATE SQL VIEW VCustomers ;

REMOTE CONNECTION Northwind ; AS SELECT * FROM Customers

*Զͼעͼݿ⣨DBCһԱȽDBC USE VCustomers *Զͼ BROWSE

*Զͼ

ݿDBCеġӶ

ǵǰǽӿԴط DSNsDBCôDSNDSNӶʲô

DSNӶΪԶͼDSNӲԡ֪ÿһSQL ServerӶҪշѵģӾͿʡǮǻ֪SQL ServerÿӴԼҪȥ24Kڴռ䣬˽24K࣬SQL ServerǷֻһʹһӡһӡϵͳЧһӰ졣۴ӿɱϵͳЧʵĽǶȣӶǿԱȻѡ

Ϊ˵ʲôǹӣΪ֤DSNӲΪͼ飺

CREATE SQL VIEW VOrders ;

REMOTE CONNECTION Northwind SHARE;

ϵͷ779662525#qq.com(#滻Ϊ@)