MFC ´úÂëÅäÖÃACCESSµÄODBCÁ¬½Ó
SQLConfigDataSource
´´½¨ODBCÊý¾ÝÔ´¿ÉÒÔµ÷ÓÃWindowsϵͳ×ÓÄ¿
¼ÏµĶ¯Ì¬Á´½Ó¿âOdbcint.dllÖеĺ¯ÊýSQLConfigDataSource()
¸Ãº¯Êý¿ÉÒÔ¶¯Ì¬µØÔö¼Ó¡¢Ð޸ĺÍɾ³ý
Êý¾ÝÔ´¡£
SQLConfigDataSource()º¯Êý
SQLConfigDataSource()µÄÔÐÍÈçÏÂ:
BOOL SQLConfigDataSource(HWND hwndParent, UINT
fRequest,LPCSTR IpszDriver, LPCSTR IpszAttributes);
ÆäÖÐËĸö²ÎÊýµÄÓ÷¨ÈçÏÂ:
¡ñ²ÎÊýhwndPwentÊǸ¸¼¶´°¿Ú¾ä±ú¡£Èç¹û¾ä±ú
ΪNULL£¬½«²»»áÏÔʾһЩÓйصĶԻ°¿ò¡£
Èç¹û²ÎÊý IpszAttributesÌṩµÄÐÅÏ¢²»¹»ÍêÉÆ£¬
ÔÚ´´½¨¹ý³ÌÖоͻá³öÏÖ¶Ô»°¿òÒªÇóÓû§ÌṩÏàÓ¦ÐÅ
Ï¢¡£
¡ñ²ÎÊýfRequest¿ÉÒÔÉèÖÃΪÏÂÃæµÄÊýÖµÖ®Ò»:
ODBC£ßADD£ßDSN: Ôö¼Ó£ß¸öÐÂÊý¾ÝÔ´
ODBC£ßCONHG£ßDSN: ÅäÖã¨ÐÞ¸Ä)Ò»¸öÒѾ´æÔÚµÄÊý¾ÝÔ´
ODBC£ßREMOVE£ßDSN: ɾ³ýÒ»¸öÒѾ´æÔÚµÄÊý¾ÝÔ´
ODBC£ßADD£ßSYS£ßDSN:. Ôö¼ÓÒ»¸öеÄϵͳÊý¾ÝÔ´
ODBC_CONFIG—SYS—DSN£º ¸ü¸ÄÒ»¸öÒѾ´æÔÚµÄϵͳÊý¾ÝÔ´
ODBC£ßREMOVE£ßSYS£ßDSN:. ɾ³ýÒ»¸öÒѾ´æÔÚµÄϵͳÊý¾ÝÔ´
¡ñ²ÎÊýlpszDriverÊÇÊý¾Ý¿âÒýÇæÃû³Æ£¬¿ÉÒԲμû
ODBC¹ÜÀíÆ÷ÖжÔODBCÇý¶¯³ÌÐòµÄÃèÊö¡£±ÈÈçÒª¼Ó
ÔصÄÊÇExcelÊý¾Ý¿â£¬ÄÇôÊý¾Ý¿âÒýÇæÃû³Æ¾ÍΪMicrosoft Excel Driver(*.xls)
¡ñ²ÎÊýlpszAttributesΪһÁ¬´®µÄ"KeyName=value"
×Ö·û´®£¬Ã¿Á½¸öKeyNameÖµÖ®¼äÓÃ""×Ö
·û¸ô¿ª¡£KeyNameÖ÷ÒªÊÇÐÂÊý¾ÝԴȱʡµÄÇý¶¯³ÌÐò
×¢²á˵Ã÷£¬ÆäÖÐ×îÖ÷ÒªµÄ¹Ø¼ü×ÖÊÇ"DSN"----- ÐÂ
Êý¾ÝÔ´µÄÃû³Æ£¬ÆäÓà¹Ø¼ü×ÖÔò¸ù¾Ý²»Í¬µÄÊý¾ÝÔ´ÓÐ
²»Í¬ÒªÇó¡£¹ØÓÚlpszAttributes²ÎÊýµÄ¾ßÌåÉèÖã¬Ïê
ϸ¿ÉÒԲο¼WindowsϵͳĿ¼Ï°ïÖúÎļþ
Odbcjtn.hlpÖ÷ÌâĿ¼±êÇ©ÖеÄ"ODBC APIº¯Êý¸Ä
±ä|SQLConfigDatasource"ÌõÄ¿¡£
2.SqlConfigDataSourceµÄÓ¦ÓÃÌõ¼þ
ʹÓÃSqlConfigDataSourceº¯Êý֮ǰ£¬±ØÐë°Ñ
ODBCINST.HÎļþ°üº¬ÔÚ¹¤³ÌÍ·ÎļþÖУ¬½«ODBC-
CP32.LIB¼ÓÈ˹¤³Ì£¬Í¬Ê±±£Ö¤ODBCCP32.DLL
ÔËÐÐʱ´¦ÓÚϵͳ×ÓĿ¼Ï¡£
Àý:
SQLConfigDataSource(NULL,ODBC_ADD_DSN, "PostgreSQL",
"DSN=abc\0"
"Description=abcdef\0"
"Server=192.168.0.1\0"
"DataBase=mybase\0"
"ReadOnly=0\0"
"Port=5432\0");
3.lpszAttributes²ÎÊýµÄʹÓÃʵÀý£¨²ÎÊý±È½ÏÌرð£©
CString strDB;
this->Get
Ïà¹ØÎĵµ£º
Access µÄ SQL ÖУ¬¼ÆËãÏàÓ¦±àºÅµÄ¼Ç¼֮¼ä ¼Ó ¼õ µÄ²éѯÃüÁî
ÀýÈç ¼ÆËãIDΪ 6 µÄ ºÏ¼Æ ¼õÈ¥ ID Ϊ 2¡¢3¡¢4 ÒÔ¼°¼ÓÉÏ ID Ϊ 5 µÄºÏ¼Æ
SELECT SUM(R) AS ½á¹û
from
(
SELECT ºÏ¼Æ AS R from T1 WHERE (ID = 6) UNION
SELECT -ºÏ¼Æ AS R from T1 WHERE (ID = 2) UNION
SELECT -ºÏ¼Æ AS R f ......
9.3 ͨ¹ýPHP²Ù×÷AccessÊý¾Ý¿â
9.3.1 Á¬½ÓAccessÊý¾Ý¿â
ÔÚPHPÖÐÁ¬½ÓAccessÓÐÈçÏÂ3ÖÖ·½Ê½¡£
£¨1£©´´½¨ÏµÍ³Êý¾ÝÔ´£¬ÓÃPHPÌṩµÄODBCº¯Êý
¼´¿É¡£
£¨2£©Í¬Ñù¿ÉÒÔʹÓÃPHPµÄODBCº¯Êý£¬µ«²»´´½¨
Êý¾ÝÔ´¡£¿ª·ÅÊý¾Ý¿âÁ¬½Ó£¨Open DateBase
Conection£¬ODBC£©ÊÇWindows Open
Server£¨¿ª·Å·þÎñ£©API£¨WOSA£©²úÆ·Ö®Ò ......
9.3 ͨ¹ýPHP²Ù×÷AccessÊý¾Ý¿â
9.3.1 Á¬½ÓAccessÊý¾Ý¿â
ÔÚPHPÖÐÁ¬½ÓAccessÓÐÈçÏÂ3ÖÖ·½Ê½¡£
£¨1£©´´½¨ÏµÍ³Êý¾ÝÔ´£¬ÓÃPHPÌṩµÄODBCº¯Êý
¼´¿É¡£
£¨2£©Í¬Ñù¿ÉÒÔʹÓÃPHPµÄODBCº¯Êý£¬µ«²»´´½¨
Êý¾ÝÔ´¡£¿ª·ÅÊý¾Ý¿âÁ¬½Ó£¨Open DateBase
Conection£¬ODBC£©ÊÇWindows Open
Server£¨¿ª·Å·þÎñ£©API£¨WOSA£©²úÆ·Ö®Ò ......