ÀýÈý
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±íµÄÖ÷¹Ø¼ü×ÖÊÇÒ»¸ö¸´ºÏ¹Ø¼ü×Ö£¬ÓÐorderidÓëproductidÁªºÏ×é³É£¬ËùÒÔÕâÀï¾ÍÒª½«ËûÃÇÒ»ÆðÌîÈë¡£
Ò»¸öºÜÖØÒªµÄÊôÐÔ¡ª¡ªWhereType
µ±ÎÒÃÇÉ趨½á¹û¼¯Îª¿É¸üйâ±êºó£¬»¹ÓÐÒ»¸öÖØÒªµÄÊôÐÔûÓÐÉ趨£¬¾ÍÊÇWhereType¡£¼´£¬Where×Ö¾ä²úÉúµÄÒÀ¾Ý£¬ÓÐËÄÖÖÇé¿ö£º
CURSORSETPROP(\¸ù¾Ý¹Ø¼ü×Ö
CURSORSETPROP(\¸ù¾Ý¹Ø¼ü×Ö£«¿É¸üÐÂ×ֶΠCURSORSETPROP(\¸ù¾Ý¹Ø¼ü×Ö+ÒѸüÐÂ×ֶΠCURSORSETPROP(\¸ù¾Ý¹Ø¼ü×Ö£«Ê±¼ä´Á
¸üÏêϸµÄÄÚÈÝ´ó¼Ò¿ÉÒԲο´¡°Ô¶³ÌÊÓͼ¡±Õ½ڣ¬ÔÚÄÇÀïÃæÎÒÒѾ½²µÃºÜ¶àÁË¡£
from [order
ËÄ¡¢ÓÃvfpÓësql server¹¹½¨Client/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 Ó¦ÓóÌÐò¡·Ò»ÎÄ£¬·Ç³£Ï£ÍûµÃµ½Äú±¦¹óµÄ½¨Òé¡£
˵ÔÚÇ°Ãæ
ÓÉÓÚ±¾ÎÄÊÇÔÚÁ½ÌìÖ®ÄڸϳöÀ´µÄ£¬¹¹Ë¼²»¹»ÑÏÃÜ£¬ÎÒÔÚÑ¡Ôñ SQL Server ¶ËÊý¾Ý¿âʱ·¸ÁËÒ»¸ö´íÎó£ºNorthwind Êý¾Ý¿âÖоø´ó¶àÊý¡°×Ö·û´®¡±ÐÍ×ֶΣ¨ÁУ©Ê¹ÓÃÁË nVarchar ÐÍ£¬Visual FoxPro ¶Ô´ËÖ§³ÖµÄ²»ºÃ£¨¾ßÌåÔÒò±¾Õ¾½«ÁíÎÄÂÛÊö£©¡£ÒÔÉÏ¿ÉÄÜÔì³ÉÑÝʾ³ÌÐò²»ÄÜÕý³£¹¤×÷£¬¶Ô´ËÎÒÃÇ¿ÉÒÔÔÚ SQL Server µÄ Enterprise Manager ÖаÑÓйØ×ֶεĵÄÀàÐÍ´Ó nVarchar ¸ÄΪ Varchar¡£ÎÒ½¨Òé°Ñ Customers ±íÖÐµÄ CustomerID ºÍ Phone×ֶεÄÀàÐͱ仯¼´¿É¡£Í¬ÑùµÄ£¬ÎÒÃÇ¿ÉÒÔ°Ñ Employees µÄ Notes ×Ö¶ÎÀàÐͱäΪ text¡£
²»ÊÇÎҵĴí
Visual FoxPro µÄÊÓͼÉè¼ÆÆ÷ËäÈ»ÄÜÍê³ÉÐí¶à·³È˵ÄÔ¶³ÌÊÓͼµÄ²Ù×÷£¬µ«¶ÔÓÚÌرð¸´ÔÓµÄÔ¶³ÌÊÓͼ¿ÉÄÜ»áÖ§³ÖºÜ²î¡£ÔÚÔĶÁ±¾ÎÄ×öʵÑéʱ£¬Óöµ½ÒÔÉÏÎÊÌâÇë²»ÒªÔð¹Ö×÷Õß¡£Visual FoxPro µÄÔ¶³ÌÊÓͼµÄ¹¦Äܷdz£Ç¿´óµÄ£¬´óµ½¹¤¾ß³ÌÐò¡°ÊÓͼÉè¼ÆÆ÷¡±²»ÄܺܺõÄÖ§³Ö£¡
Ç°ÑÔ
Visual FoxPro Ϊ Client/Server ¹¹¼ÜµÄÓ¦ÓÃÌṩÁËÁ½¸öÄÚÖõĽâ¾ö·½°¸£ºÔ¶³ÌÊÓͼ(Remote Views)Óë SPT(SQL pass through)¡£µ±È»ÔÚVisual FoxProÖÐÎÒÃÇ¿ÉÒÔʹÓÃÆäËüµÄÔ¶³ÌÊý¾ÝÁ¬½ÓµÄ·½·¨£¬±ÈÈç ADO¡£ËùÓÐÕâЩ½â¾ö·½°¸¶¼¸÷ÓÐÓÅÁÓ£¬Ô¶³ÌÊÓͼ×î´óµÄºÃ´¦¾ÍÊÇËü¿ÉÒԷdz£·½±ãµØÓëVisual FoxProÄÚÖÿؼþ°ó¶¨¡£Ã¿Ò»¸öÔ¶³ÌÊÓͼ¾ÍÊÇÒ»¸ö´æ´¢ÓÚVisual FoxProÊý¾Ý¿âÈÝÆ÷£¨DBC£©µÄ¶ÔÏó£¬ÊÇÒ»¾äSQL-SELECTÓï¾ä¡£Ô¶³ÌÊÓͼͨ¹ýODBC£¨Open Database Connectivity)ÓëÒì¹¹Êý¾Ý¿âͨѶ¡£
ËäÈ»±¾ÎĵÄʵÀýʹÓÃSQL Server ×÷Ϊºó¶ËÊý¾Ý¿â£¬µ«´ó¼ÒͬÑù¿ÉÒÔʹÓÃÆäËüÊý¾ÝÔ´×÷Ϊºó¶ËÊý¾Ý¿â£¬ÀýÈç Oracle£¬IBM DB2£¬Informix,Sybase,Microsoft Access,Excel,ÉõÖÁÊÇVisual FoxPro×Ô¼º¡£Ê¹ÓÃÔ¶³ÌÊÓͼ²Ù×÷Ô¶³ÌÊý¾Ý¾ÍÏñ²Ù×÷Visual FoxPro±¾µØÊý¾ÝÒ»°ã£¬ÒÔÏÂÎÒÃǽ«½éÉÜÕâһΰ´ó¹¤¾ßµÄ³õ¼¶Ó¦Óá£
Á¬½Ó-Connections
ʹÓÃÔ¶³ÌÊÓͼ²Ù×÷Ô¶³ÌÊý¾ÝµÄµÚÒ»²½¾ÍÊǽ¨Á¢ÓëÔ¶³ÌÊý¾ÝÔ´µÄͨѶ£¬ÕâÀïÓкü¸ÖÖ·½·¨¿É¹©Ñ¡Ôñ£¬Çë×¢ÒâËùÓÐÕâЩ·½·¨¶¼Ê¹Óà ODBC ÓëÔ¶³ÌÊý¾ÝÁ¬½Ó¡£
ÕâÀïÓÐÒ»¸ö·Ç³£¼òµ¥µÄÔ¶³ÌÊÓͼ£¬ËüµÄ×÷ÓÃÊÇ£º¶ÁÈ¡ 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 µÄµÇ¼Êý¾Ý¿â
·Ï»°¾Í²»¶à˵ÁË£¬Èç¹ûһЩ˳Àû£¬ÕâÌõ½Ð¡°Northwind¡±µÄSystem DSN ¾Í½¨³ÉÁË¡£
ÔÚVisual FoxProµÄÃüÁî´°¿ÚÖн¨Á¢ÈçÏÂÓï¾ä£º
CREATE DATABASE Northwind
*½¨Á¢±¾µØÊý¾Ý¿âÈÝÆ÷£¬´æ´¢Êý¾Ý¿â¶ÔÏó¡£ CREATE SQL VIEW VCustomers ;
REMOTE CONNECTION Northwind ; AS SELECT * FROM Customers
*½¨Á¢Ô¶³ÌÊÓͼ£¬×¢ÒâÕâ¸öÊÓͼÊÇÊý¾Ý¿â£¨DBC£©µÄÒ»¸ö¶ÔÏó£¬ËùÒÔ±ØÐëÏȽ¨Á¢DBC USE VCustomers *´ò¿ªÔ¶³ÌÊÓͼ BROWSE
*ä¯ÀÀÔ¶³ÌÊÓͼ
½¨Á¢Êý¾Ý¿âÈÝÆ÷£¨DBC£©Öеġ°Á¬½Ó¶ÔÏó¡±
¼ÇµÃÔÚÇ°ÎÄÎÒÃǽ²¹ýÁ¬½Ó¿ÉÒÔ´æÔÚÓÚÁ½¸öµØ·½£¬¾ÍÊÇ DSNsÓëDBC£¬ÄÇôDSNÓë»ùÓÚDSNµÄÁ¬½Ó¶ÔÏóÓÐʲôÇø±ð£¿
»ùÓÚDSNµÄÁ¬½Ó¶ÔÏó¿ÉÒÔΪÊý¸öÔ¶³ÌÊÓͼ¹²Ïí£¬¶øDSNÁ¬½Ó²»¿ÉÒÔ¡£ÎÒÃÇÖªµÀ£¬Ã¿Ò»ÌõÓëSQL ServerµÄÁ¬½Ó¶¼ÊÇÒªÊշѵģ¬¹²ÏíÁ¬½Ó¾Í¿ÉÒÔÊ¡Ç®£»ÎÒÃÇ»¹ÖªµÀ£¬SQL Server¹ÜÀíÿÌõÁ¬½Ó´óÔ¼Òª»¨È¥24KµÄÄÚ´æ¿Õ¼ä£¬ÓÐÈ˽²£º24K²»¶à£¬µ«Äú±ðÍüÁËSQL ServerÊÇ·þÎñÆ÷£¬²»Ö»ÊÇÄúÒ»¸öÈËʹÓÃËü¡ª¡ª¶«Ò»ÌõÁ¬½Ó¡¢Î÷Ò»ÌõÁ¬½Ó¡ª¡ªÏµÍ³Ð§ÂÊÒ»¶¨»áÊÜÓ°Ïì¡£Òò´ËÎÞÂÛ´Ó¿ª·¢³É±¾»¹ÊÇϵͳ¹¤×÷ЧÂʵĽǶȣ¬¹²ÏíÁ¬½Ó¶¼ÊÇ¿ª·¢ÈËÔ±±ØÈ»µÄÑ¡Ôñ¡£
ΪÁË˵Ã÷ʲôÊǹ²ÏíÁ¬½Ó£¬ÎªÁËÖ¤Ã÷DSNÁ¬½Ó²»ÄÜΪÊÔͼ¹²Ïí£¬ÎÒÃÇ×öÒÔÏÂÊÔÑ飺
CREATE SQL VIEW VOrders ;
REMOTE CONNECTION Northwind SHARE;