ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[±Ð¾Ç] (ASP±Ð¾Ç²Ä13½g) ¸ê®Æ®wÅX°Êµ{¦¡ ¤W½g

[±Ð¾Ç] (ASP±Ð¾Ç²Ä13½g) ¸ê®Æ®wÅX°Êµ{¦¡ ¤W½g

²{¤µªººô¸ô¹q¤l°Ó°È§K¤£¤F­n»P¸ê®Æ®w§è¤WÃö«Y¡A³o¸Ì©Ò«üªº¸ê®Æ®w¬O¡GWeb Server ¤Wªº¸ê®Æ®w³á¡I¨ä¹ê¸ê®Æ®w¤£´N¬O¤@­ÓÀɮסA¦ý¬O¡A¥¦¬O¤@­Óµ²ºc¤ÆÀx¦s¸ê®Æªº®æ¦¡ÀɮסC¨ä¹ê§Ú­Ì±`±`¦b¨Ï¥Î¸ê®Æ®w¦Ó¤£¦Ûª¾¡A«ç»ò»¡?§A¦³¨S¦³¾Þ§@¹L.mdb ªºÀÉ®×°Ú?¥¦´N¬O¤@­Ó Access ®æ¦¡ªº¸ê®Æ®wÀɮסC

­n¦s¨úºô¸ô¦øªA¾¹¤Wªº¸ê®Æ®w¥i¬O¸ò§Ú­Ì³æ¾÷¤Wªº¾Þ§@¦³«Ü¤j¤£¦P¡I¦bASPºô­¶¤¤­n¦s¨úºô¸ô¦øªA¾¹¤Wªº¸ê®Æ®w¡A¥²¶·¨Ï¥Î¦s¨ú¸ê®Æ®wªºª«¥ó ADO(ActiveX Data Objects)¡A ADO ¬O¦s¨ú¸ê®Æ®wª«¥ó­Ìªº²ÎºÙ¡A§Ú­Ì¥D­n¥Î¨Ó¦s¨ú¸ê®Æ®wªºª«¥ó¦³¤U¦C¤TºØ

  • Connection ª«¥ó
  • Recordset ª«¥ó
  • Command ª«¥ó


    ¦bASP¤¤¨Ï¥ÎADOª«¥ó´N¥i¥H¦s¨ú¸ê®Æ®w¤F¶Ü?·íµM¬O¤£¦æ¡I°£¤FADOª«¥ó¥~§Ú­ÌÁÙ­n¦³ODBCÅX°Êµ{¦¡¡A¦]¬°§Ú­Ì¦s¨ú¥ô¦ó¤@ºØ¸ê®Æ®w³£¥²¶·¦³¨ä¬Û¹ïÀ³ªºODBCÅX°Êµ{¦¡¡AADOª«¥ó¤~¯à°÷¹ï¸ê®Æ®wªºÀɮק@¦s¨úªº°Ê§@¡I


¸ê®Æ®wÅX°Êµ{¦¡
§Ú­Ì¦s¨ú¥ô¦ó¤@ºØ¸ê®Æ®w³£¥²¶·¦³¨ä¬Û¹ïÀ³ªº¸ê®Æ®wÅX°Êµ{¦¡¡AADOª«¥ó¤~¯à°÷¹ï¸ê®Æ®wªºÀɮק@¦s¨úªº°Ê§@¡I

  • ODBC (Open DataBase Connectivity)
  • OLE DB (Object Linking and Embedding DataBase)

    ¥H¤W³o¨âªÌ¬Ò¬°ÅX°Êµ{¦¡Ãþ§O¡AÀ³¥Îµ{¦¡¥iÂǥѦ¹ÅX°Êµ{¦¡¤¶­±¨Ó¦s¨ú¸ê®Æ®wªº¸ê®Æ¡A¤]´N¬O»¡­n¨ÏADOª«¥ó¥i¥H¦s¨ú¸ê®Æ®w¡A´N¥²¶·¦w¸Ë¬Û¹ïÀ³¤§ÅX°Êµ{¦¡¡A¦p¤U¹Ï©Ò¥Ü¡C
1.png

¤£¦Pªº¸ê®Æ®wÅX°Êµ{¦¡¡A¦s¨ú¬Û¹ïÀ³¤§¸ê®Æ®wÃþ«¬
    ½Ð¤£­n·d¿ù¤F³á¡IODBC»POLEDB¥u¬OÅX°Êµ{¦¡­Ìªº²ÎºÙ¦Ó¤w¡A¨C¤@ºØ¤£¦PÃþ«¬ªº¸ê®Æ®w³£¾Ö¦³¦Û¤v¬Û¹ïÀ³ªºÅX°Êµ{¦¡¡A¦p¤Uªí©Ò¥Ü¡G

ÅX°Êµ{¦¡¦WºÙ

ª©¥»

¹ïÀ³¤§¸ê®Æ®w

Microsoft Access driver

3.51

Accessªºmdb¸ê®Æ®w

Microsoft ODBC for Oracle

2.73

Oracle¸ê®Æ®w

SQL Server

3.50

SQL Server¸ê®Æ®w

Microsoft.jet.OLEDB

4.0

Access2000¸ê®Æ®w

SQLoledb.1

1.0

SQL7.0ª©¸ê®Æ®w



¦pªG§A¤w¸g¦w¸Ë¤F IIS/PWS 4.0 ª©¡A«h¦Ü¤Ö·|¦³¤U¦C¤TºØ¸ê®Æ®wÅX°Êµ{¦¡¡G

ÅX°Êµ{¦¡¦WºÙ

ª©¥»

¹ïÀ³¤§¸ê®Æ®w

Microsoft Access driver

3.51

Accessªºmdb¸ê®Æ®w

Microsoft ODBC for Oracle

2.73

Oracle¸ê®Æ®w

SQL Server

3.50

SQL Server¸ê®Æ®w



¨º§Ú­n¨Ï¥ÎAccess2000¸ê®Æ®w®É«ç»ò¿ì¡H¨ä¹ê¡A§A¥u­n¦w¸Ë¸û·sªº³nÅé«á´N·|ªþ¦³¬ÛÃöªº³Ì·s¸ê®Æ®wÅX°Êµ{¦¡¡A­n¤£µM§A¤]¥i¥Hª½±µ³s¤W·L³nªººô¯¸¤U¸ü¦w¸Ë³Ì·sªº¸ê®Æ®wµ{¦¡¡A¦pªG§A¬O¨Ï¥Î IIS 5.0ª©¨º±z´N¤j¥i©ñ¤ß¤F¡A¦]¬° IIS 5.0¤w¸g´£¨Ñ¤F·sª©ªº¸ê®Æ®wÅX°Êµ{¦¡¤F¡C

¬d¬Ý¤w¦w¸ËªºÅX°Êµ{¦¡
    ¦b§Ú­Ìªº¾÷¾¹¤W¨ì©³¦w¸Ë¤F­þ¨ÇODBC¸ê®Æ®wÅX°Êµ{¦¡©O¡H­n¬d¬Ý§Ú­Ì¾÷¾¹¤W¦w¸Ë¤F­þ¤@¨Ç¸ê®Æ®wÅX°Êµ{¦¡¡A­º¥ý¡A§Ú­Ì¥²¶·¥ý¥´¶}¡y±±¨î¥x¡z¡AµM«á¦A¶}±Ò¡yODBC ¸ê®Æ¨Ó·½¡z¶µ¥Ø¡G
2.png

¦b¶}±Ò¡yODBC ¸ê®Æ¨Ó·½¡z¶µ¥Ø«á¡A±µµÛ´N·|¥X²{¡yODBC ¸ê®Æ¨Ó·½ºÞ²z­û¡z¹ï¸Üµøµ¡¡A§Ú­Ìª½±µ¤Á´«¦Ü¡yÅX°Êµ{¦¡¡z¿ï¶µ­¶¡A´N¥i¥H¬Ý¨ì¤w¦w¸Ë¦b§Ú­Ì¾÷¾¹¤Wªº¸ê®Æ®wÅX°Êµ{¦¡¡A¦p¤U¹Ï©Ò¥Ü¡A¦b§Aªº¾÷¾¹¤¤¤w¦w¸Ëªº¸ê®Æ®wÅX°Êµ{¦¡¥i¯à·|¤ñ¤U¹Ï¦h©Î¤Ö¡A¼Æ¥Ø¦h¤Ö­n¬Ý§A¦w¸Ë¤F¦h¤Ö³nÅé¦Ó©w¡A¦]¬°«Ü¦hªº³nÅé¦b§Ú­Ì°õ¦æ¦w¸Ë®É±`±`·|¦Û°ÊªºÀ°§Ú­Ì¦w¸Ë¤F¬Y¨ÇODBC¸ê®Æ®wÅX°Êµ{¦¡¡G
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

ADOª«¥ó¸s¤§Connectionª«¥ó
Connection ª«¥ó¬O­t³d»P¸ê®Æ®w¹ê»Úªº³sµ²°Ê§@¡A«Ø¥ß»Pºô¸ô¦øªA¾¹¸ê®Æ®wªº³sµ²¬O¶i¦æ¸ê®Æ®w¦s¨úªº²Ä¤@¨B¡A­Y¨S¦³ Connection ª«¥ó³sµ²¸ê®Æ®w¡A«hªÅ¦³¨ä¥Lª«¥ó¤]¨S¥Î¡A¨º§Ú­Ì­n¦p¦ó¨Ó«Ø¥ß¤@­Ó Connection ª«¥ó©O¡H¨ä¼Ð·Ç®æ¦¡¦p¤U©Ò¥Ü¡G
  1. Set ª«¥ó¦W = Server.CreateObject("ADODB.Connection")
½Æ»s¥N½X
¤W¦¡¤¤ªº¡yª«¥ó¦W¡z¬O§Ú­Ì¦Û­qªº¡A¨Ã¨S¦³±j¨î©Êªº©R¦W³W©w¡A¤£¹L¡A³Ì¦n¬O¨ú¤@­Ó¦³·N¸qªº¦W¦r¡A¥H¤è«K§Ú­Ì¨Ï¥Î»P°O¾Ð¡C

«Ø¥ß¤F Connection ª«¥ó«á§Ú­Ìºò±µµÛ´N­n§Q¥Î³o­Ó Connection ª«¥óªº¡yOpen¡z¤èªk¨Ó³sµ²¸ê®Æ®w¡A¤U¨Ò¬°¤@­Ó³sµ²Access2000 ®æ¦¡ªº test.mdb ¸ê®Æ®wÀÉ®×½d¨Ò¡G
1.png
1.«Ø¥ß¤@­Óª«¥ó¦W¬° cn ªºConnection ª«¥ó
  1. Set cn = server.createobject("ADODB.Connection")
½Æ»s¥N½X
2.¨Ï¥ÎÅܼÆProvide ¨Ó«ü©w§Ú­Ì­n¨Ï¥Îªº¸ê®Æ®wÅX°Êµ{¦¡¡A¦]¬°§Ú­Ì­n¶i¦æ³sµ²¦s¨úªº¸ê®Æ®wÀÉ®×Ãþ«¬¬° Access ®æ¦¡¡A©Ò¥H¨Ï¥Îªº¸ê®Æ®w°Ï¹ïµ{¦¡¬°¡Gmicrosoft.jet.oledb.4.0
  1. provider = "provider = microsoft.jet.oledb.4.0;"
½Æ»s¥N½X
3.¨Ï¥ÎÅܼÆPath ¨Ó«ü©w§Ú­Ì­n¨Ï¥Îªº¸ê®Æ®w¸ô®|»PÀɦW¡A
  1. path = "data source=" & server.mappath("test.mdb")
½Æ»s¥N½X
§Ú­Ì­n¶i¦æ³sµ²¦s¨úªº¸ê®Æ®wÀɮסA¥²¶·«ü©w¦¹¸ê®Æ®wÀɮתº§¹¾ã¸ô®|¦WºÙ¡A©Ò¥H§Ú­Ì¥²¶·¨Ï¥Î¡yServer.MapPath¡z¤èªk¨Ó¨ú±o¸ê®Æ®wÀɮתº§¹¾ã¸ô®|¦WºÙ¡C

4.±µµÛ¨Ï¥Î Open ¤èªk¨Ó¶}±Ò§Ú­Ì«ü©w¸ê®Æ®wÀÉ®×


­«ÂI:¤W­zªº»¡©ú¦³¨â­Ó­«­nªº´£ÂI¡G
1.¨Ï¥Î Connection ª«¥óªº¡yOpen¡z¤èªk¨Ó³sµ²¡ymdb¡z¸ê®Æ®w¥²¶·µ¹¤©¨â­Ó°Ñ¼Æ¡Gprovider (ÅX°Êµ{¦¡¦WºÙ)¡Bdata source(¸ê®Æ®w¨Ó·½)
2.§â´¤¡yOpen¡z¨â­Ó°Ñ¼Æªº¨Ï¥Î¡A§Ú­Ì¥i±N¨BÆJ¢±¢²¢³¦X¨Ö¨Ó¼g¡G
  1. cn.open "provider = microsoft.jet.oledb.4.0;data source=" & server.mappath("test.mdb")
½Æ»s¥N½X
¡y¡F¡z¤À¸¹¬°°Ñ¼Æ¶¡ªº¤À¹j²Å¸¹¡A¤£¥i¬Ù²¤®@¡I

¤Uªí¬°§Q¥ÎConnection ª«¥óªº¡yOpen¡z¤èªk¨Ó³sµ²¡ymdb¡z¸ê®Æ®w¥²¶·µ¹¤©ªº°Ñ¼Æ¡G

°Ñ¼Æ

³]©w­È

Provider

microsoft.jet.oledb.4.0

Data Source

¹ê»Ú¸ô®|ÀɮצWºÙ

jet oledb:database password

±K½X




§A¦b·Q¤°»ò¡H
    ¨º­Ó¡y±K½X¡z°Ñ¼Æ¹ï¤£¹ï¡H§Ú¨S¼g¿ù°Õ¡I¦pªG§Ú­Ì­n³sµ²ªºmdb¸ê®Æ®w¦³³]©w±K½X¡A¨º»ò§Ú­Ì´N­n¨Ï¥Î³o­Ó°Ñ¼Æ¤F°Õ¡I°²³]§Ú­Ì­n³sµ²¶}±Òªº¸ê®Æ®w¦³³]©w±K½X"123"¡A¨º»ò§Ú­Ì´N¥²¶·¥[¤J¤U­±³o²Õ°Ñ¼Æ¡G
  1. Jet OLEDB:Database Password=123
½Æ»s¥N½X
¤£¦Pªº¸ê®Æ®wÅX°Êµ{¦¡¡A¤£¦Pªº°Ñ¼Æ
³sµ²¤£¦PÃþ«¬ªº¸ê®Æ®w­n¨Ï¥Î¤£¦Pªº¹ïÀ³ÅX°Êµ{¦¡¡A¨S§Ñ°O§a¡I¤£¦PªºÅX°Êµ{¦¡·íµM¥¦­Ìªº°Ñ¼Æ²Õ¦X¤]´N¤£¦P¤F¡A¨C¤@ºØ¤£¦PÅX°Êµ{¦¡³£¦³¨ä¯S©wªº°Ñ¼Æ®æ¦¡¡G
³sµ²Dbf¸ê®Æ®w

°Ñ¼Æ

³]©w­È

Provider

{microsoft visual foxpro driver}

Source DB

¹ê»Ú¸ô®|ÀɮצWºÙ

Source Type

DBF



³sµ²Dbc¸ê®Æ®w

°Ñ¼Æ

³]©w­È

Provider

{microsoft visual foxpro driver}

Source DB

¹ê»Ú¸ô®|ÀɮצWºÙ

Source Type

DBC



³sµ²Excel¸ê®Æ®w

°Ñ¼Æ

³]©w­È

Driver

{microsoft excel driver(*.xls)}

DBQ

¹ê»Ú¸ô®|ÀɮצWºÙ



³sµ²Text¸ê®Æ®w

°Ñ¼Æ

³]©w­È

Driver

{microsoft excel driver(*.txt;*cvs)}

DBQ

¹ê»Ú¸ô®|ÀɮצWºÙ



³sµ²SQL¸ê®Æ®w

°Ñ¼Æ

³]©w­È

Provider

SQLOLEDB.1

Data Source

server name

User ID

¨Ï¥ÎªÌID

Password

±K½X

Initial Catalog

¸ê®Æªí¦WºÙ



¸ê®Æ®wÅX°Êµ{¦¡¦WºÙ­þ¸Ì¨Ó¡H
    ³sµ²¤£¦PÃþ«¬ªº¸ê®Æ®w­n¨Ï¥Î¤£¦Pªº¹ïÀ³ÅX°Êµ{¦¡¡A³o¬Oµ§ªÌ¤@¦A±j½Õªº¡A¨º»ò§Ú­Ì¦p¦ó±oª¾¸ê®Æ®wÅX°Êµ{¦¡ªº¦WºÙ©O¡H¥ý¥´¶}¡y±±¨î¥x¡z¡AµM«á¦A¶}±Ò¡yODBC ¸ê®Æ¨Ó·½¡z¶µ¥Ø¡A¶}±Ò¡yODBC ¸ê®Æ¨Ó·½¡z¶µ¥Ø«á¡A±µµÛ´N·|¥X²{¡yODBC ¸ê®Æ¨Ó·½ºÞ²z­û¡z¹ï¸Üµøµ¡¡A§Ú­Ìª½±µ¤Á´«¦Ü¡yÅX°Êµ{¦¡¡z¿ï¶µ­¶¡Aª`·N¬Ý¨ì¡y¦WºÙ¡zÄæ¦ì¡A³o¨Ç±ø¦Cªº¶µ¥Ø´N¬O¶}±Ò¬ÛÃö¸ê®Æ®wªºÅX°Êµ{¦¡¦WºÙ¡I

ª`·N¡G¨ú¥Î³o¨ÇÅX°Êµ{¦¡¦WºÙ¡A¥²¶·¤@¦r¤£º|ªº§Û¼g¤U¨Ó¡A¥]¬A­^¼Æ¦r»P²Å¸¹¡A³]¸mªÅ¥Õ¦r¤¸¤]¤£¥i©ñ¹L¡I
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

        ÀR«ä¦Û¦b : ¤ß¤¤±`¦sµ½¸Ñ¡B¥]®e¡B·P«ä¡Bª¾¨¬¡B±¤ºÖ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD