ÊìϤSQL SERVER 2000µÄÊý¾Ý¿â¹ÜÀíÔ±¶¼ÖªµÀ£¬ÆäDTS¿ÉÒÔ½øÐÐÊý¾ÝµÄµ¼Èëµ¼³ö£¬Æäʵ£¬ÎÒÃÇÒ²¿ÉÒÔʹÓÃTransact-SQLÓï¾ä½øÐе¼Èëµ¼³ö²Ù×÷¡£ÔÚTransact-SQLÓï¾äÖУ¬ÎÒÃÇÖ÷ҪʹÓÃOpenDataSourceº¯Êý¡¢OPENROWSET º¯Êý£¬¹ØÓÚº¯ÊýµÄÏêϸ˵Ã÷£¬Çë²Î¿¼SQLÁª»ú°ïÖú¡£ÀûÓÃÏÂÊö·½·¨£¬¿ÉÒÔÊ®·ÖÈÝÒ×µØʵÏÖSQL SERVER¡¢ACCESS¡¢EXCELÊý¾Ýת»»£¬Ïêϸ˵Ã÷ÈçÏ£º
Ò»¡¢SQL SERVER ºÍACCESSµÄÊý¾Ýµ¼Èëµ¼³ö
³£¹æµÄÊý¾Ýµ¼Èëµ¼³ö£º
ʹÓÃDTSÏòµ¼Ç¨ÒÆÄãµÄAccessÊý¾Ýµ½SQL Server£¬Äã¿ÉÒÔʹÓÃÕâЩ²½Öè:
1ÔÚSQL SERVERÆóÒµ¹ÜÀíÆ÷ÖеÄTools£¨¹¤¾ß£©²Ëµ¥ÉÏ£¬Ñ¡ÔñData Transformation
2Services£¨Êý¾Ýת»»·þÎñ£©£¬È»ºóÑ¡Ôñ czdImport Data£¨µ¼ÈëÊý¾Ý£©¡£
3ÔÚChoose a Data Source£¨Ñ¡ÔñÊý¾ÝÔ´£©¶Ô»°¿òÖÐÑ¡ÔñMicrosoft Access as the Source£¬È»ºó¼üÈëÄãµÄ.mdbÊý¾Ý¿â(.mdbÎļþÀ©Õ¹Ãû)µÄÎļþÃû»òͨ¹ýä¯ÀÀÑ°ÕÒ¸ÃÎļþ¡£
4ÔÚChoose a Destination£¨Ñ¡ÔñÄ¿±ê£©¶Ô»°¿òÖУ¬Ñ¡ÔñMicrosoft OLE¡¡DB Prov ider for SQL¡¡Server£¬Ñ¡ÔñÊý¾Ý¿â·þÎñÆ÷£¬È»ºóµ¥»÷±ØÒªµÄÑéÖ¤·½Ê½¡£
5ÔÚSpecify Table Copy£¨Ö¸¶¨±í¸ñ¸´ÖÆ£©»òQuery£¨²éѯ£©¶Ô»°¿òÖУ¬µ¥»÷Copy tables£¨¸´ÖƱí¸ñ£©¡£
6ÔÚSelect Source ......
ÊìϤSQL SERVER 2000µÄÊý¾Ý¿â¹ÜÀíÔ±¶¼ÖªµÀ£¬ÆäDTS¿ÉÒÔ½øÐÐÊý¾ÝµÄµ¼Èëµ¼³ö£¬Æäʵ£¬ÎÒÃÇÒ²¿ÉÒÔʹÓÃTransact-SQLÓï¾ä½øÐе¼Èëµ¼³ö²Ù×÷¡£ÔÚTransact-SQLÓï¾äÖУ¬ÎÒÃÇÖ÷ҪʹÓÃOpenDataSourceº¯Êý¡¢OPENROWSET º¯Êý£¬¹ØÓÚº¯ÊýµÄÏêϸ˵Ã÷£¬Çë²Î¿¼SQLÁª»ú°ïÖú¡£ÀûÓÃÏÂÊö·½·¨£¬¿ÉÒÔÊ®·ÖÈÝÒ×µØʵÏÖSQL SERVER¡¢ACCESS¡¢EXCELÊý¾Ýת»»£¬Ïêϸ˵Ã÷ÈçÏ£º
Ò»¡¢SQL SERVER ºÍACCESSµÄÊý¾Ýµ¼Èëµ¼³ö
³£¹æµÄÊý¾Ýµ¼Èëµ¼³ö£º
ʹÓÃDTSÏòµ¼Ç¨ÒÆÄãµÄAccessÊý¾Ýµ½SQL Server£¬Äã¿ÉÒÔʹÓÃÕâЩ²½Öè:
1ÔÚSQL SERVERÆóÒµ¹ÜÀíÆ÷ÖеÄTools£¨¹¤¾ß£©²Ëµ¥ÉÏ£¬Ñ¡ÔñData Transformation
2Services£¨Êý¾Ýת»»·þÎñ£©£¬È»ºóÑ¡Ôñ czdImport Data£¨µ¼ÈëÊý¾Ý£©¡£
3ÔÚChoose a Data Source£¨Ñ¡ÔñÊý¾ÝÔ´£©¶Ô»°¿òÖÐÑ¡ÔñMicrosoft Access as the Source£¬È»ºó¼üÈëÄãµÄ.mdbÊý¾Ý¿â(.mdbÎļþÀ©Õ¹Ãû)µÄÎļþÃû»òͨ¹ýä¯ÀÀÑ°ÕÒ¸ÃÎļþ¡£
4ÔÚChoose a Destination£¨Ñ¡ÔñÄ¿±ê£©¶Ô»°¿òÖУ¬Ñ¡ÔñMicrosoft OLE¡¡DB Prov ider for SQL¡¡Server£¬Ñ¡ÔñÊý¾Ý¿â·þÎñÆ÷£¬È»ºóµ¥»÷±ØÒªµÄÑéÖ¤·½Ê½¡£
5ÔÚSpecify Table Copy£¨Ö¸¶¨±í¸ñ¸´ÖÆ£©»òQuery£¨²éѯ£©¶Ô»°¿òÖУ¬µ¥»÷Copy tables£¨¸´ÖƱí¸ñ£©¡£
6ÔÚSelect Source ......
Visual BasicÓÐ×ÅÇ¿´óµÄÊý¾Ý¿â´æÈ¡ÄÜÁ¦£¬²»½öÄܹ»Ö±½ÓÖ§³ÖMs AccessÊý¾Ý¿â£¬¶øÇÒͨ¹ýÆäÄÚ²¿°²×°µÄISAMÇý¶¯³ÌÐòʹËüÄܼä½ÓÖ§³ÖFoxPro¡¢dBASEµÈÍâÀ´Êý¾Ý¿â¡£±¾ÎIJ»½ö´ÓVBÊý¾Ý¿âÌåϵ½á¹¹µÄ½Ç¶È̽Ë÷ÁËVB¶ÔÕâЩÍâÀ´Êý¾Ý¿âµÄÖ§³Ö£¬»¹½áºÏÁËһЩʵÀý¾ßÌå²ûÊöÁËʹÓÃÊý¾Ý¿â´æÈ¡¶ÔÏó±äÁ¿µÄ·½·¨ÊµÏÖÕâЩÍâÀ´Êý¾Ý¿âµÄн¨¡¢¿â½á¹¹Ð޸ġ¢ÏÔʾ¼°ÆäÔËÐл·¾³ÉèÖá£
Visual Basic Access, ÍâÀ´Êý¾Ý¿â,Êý¾Ý¿â
ÕýÎÄ
´æÈ¡¶ÔÏó±äÁ¿¿â½á¹¹×÷Ϊһ¸ö¹¦ÄܽÏÍ걸µÄWindowsÈí¼þ¿ª·¢Æ½Ì¨£¬Visual Basicרҵ°æÌṩÁ˶ÔÊý¾Ý¿âÓ¦ÓõÄÇ¿´óÖ§³Ö¡£ÓÈÆäÌṩÁËʹÓÃÊý¾Ý¿Ø¼þºÍ°ó¶¨¿ØÖÆÏʹÓÃÊý¾Ý¿â´æÈ¡¶ÔÏó±äÁ¿£¨Data Access Object Variable£©£¬Ö±½Óµ÷ÓÃODBC 2.0 API½Ó¿Úº¯ÊýµÈÈýÖÖ·ÃÎÊÊý¾Ý¿âµÄ·½·¨¡£¶ÔÆä±ê×¼ÄÚÖõÄMs AccessÊý¾Ý¿â£¬Ëü¿ÉÒÔÌṩ²»ÈõÓÚרҵÊý¾Ý¿âÈí¼þµÄÖ§³Ö£¬¿ÉÒÔ½øÐÐÍêÕûµÄÊý¾Ý¿âά»¤¡¢²Ù×÷¼°ÆäÊÂÎñ´¦Àí¡£ÔÚVBÖУ¬½«·ÇAccessÊý¾Ý¿â³ÆΪÍâÀ´Êý¾Ý¿â¡£¶ÔÓÚFoxPro¡¢dBASE¡¢ParadoxµÈÍâÀ´Êý¾Ý¿â¡£ËäÈ»½èÖúVBµÄData Manager Äܹ»¶ÔÕâЩÊý¾Ý¿â½øÐÐNEW¡¢OPEN¡¢DESIGN¡¢DELETEµÈ²Ù×÷£¬µ«ÔÚÓ¦ÓóÌÐòµÄÔËÐÐ״̬Öв¢²»ÄܴӵײãÕæÕýʵÏÖÕâЩ¹¦ÄÜ¡£±¾ÎÄ´ÓʹÓÃÊý¾Ý¿â´æÈ¡¶ÔÏó±äÁ¿µÄ·½·¨³ö·¢£¬ÊµÏÖÁË·ÇAccess¸ ......
Visual BasicÓÐ×ÅÇ¿´óµÄÊý¾Ý¿â´æÈ¡ÄÜÁ¦£¬²»½öÄܹ»Ö±½ÓÖ§³ÖMs AccessÊý¾Ý¿â£¬¶øÇÒͨ¹ýÆäÄÚ²¿°²×°µÄISAMÇý¶¯³ÌÐòʹËüÄܼä½ÓÖ§³ÖFoxPro¡¢dBASEµÈÍâÀ´Êý¾Ý¿â¡£±¾ÎIJ»½ö´ÓVBÊý¾Ý¿âÌåϵ½á¹¹µÄ½Ç¶È̽Ë÷ÁËVB¶ÔÕâЩÍâÀ´Êý¾Ý¿âµÄÖ§³Ö£¬»¹½áºÏÁËһЩʵÀý¾ßÌå²ûÊöÁËʹÓÃÊý¾Ý¿â´æÈ¡¶ÔÏó±äÁ¿µÄ·½·¨ÊµÏÖÕâЩÍâÀ´Êý¾Ý¿âµÄн¨¡¢¿â½á¹¹Ð޸ġ¢ÏÔʾ¼°ÆäÔËÐл·¾³ÉèÖá£
Visual Basic Access, ÍâÀ´Êý¾Ý¿â,Êý¾Ý¿â
ÕýÎÄ
´æÈ¡¶ÔÏó±äÁ¿¿â½á¹¹×÷Ϊһ¸ö¹¦ÄܽÏÍ걸µÄWindowsÈí¼þ¿ª·¢Æ½Ì¨£¬Visual Basicרҵ°æÌṩÁ˶ÔÊý¾Ý¿âÓ¦ÓõÄÇ¿´óÖ§³Ö¡£ÓÈÆäÌṩÁËʹÓÃÊý¾Ý¿Ø¼þºÍ°ó¶¨¿ØÖÆÏʹÓÃÊý¾Ý¿â´æÈ¡¶ÔÏó±äÁ¿£¨Data Access Object Variable£©£¬Ö±½Óµ÷ÓÃODBC 2.0 API½Ó¿Úº¯ÊýµÈÈýÖÖ·ÃÎÊÊý¾Ý¿âµÄ·½·¨¡£¶ÔÆä±ê×¼ÄÚÖõÄMs AccessÊý¾Ý¿â£¬Ëü¿ÉÒÔÌṩ²»ÈõÓÚרҵÊý¾Ý¿âÈí¼þµÄÖ§³Ö£¬¿ÉÒÔ½øÐÐÍêÕûµÄÊý¾Ý¿âά»¤¡¢²Ù×÷¼°ÆäÊÂÎñ´¦Àí¡£ÔÚVBÖУ¬½«·ÇAccessÊý¾Ý¿â³ÆΪÍâÀ´Êý¾Ý¿â¡£¶ÔÓÚFoxPro¡¢dBASE¡¢ParadoxµÈÍâÀ´Êý¾Ý¿â¡£ËäÈ»½èÖúVBµÄData Manager Äܹ»¶ÔÕâЩÊý¾Ý¿â½øÐÐNEW¡¢OPEN¡¢DESIGN¡¢DELETEµÈ²Ù×÷£¬µ«ÔÚÓ¦ÓóÌÐòµÄÔËÐÐ״̬Öв¢²»ÄܴӵײãÕæÕýʵÏÖÕâЩ¹¦ÄÜ¡£±¾ÎÄ´ÓʹÓÃÊý¾Ý¿â´æÈ¡¶ÔÏó±äÁ¿µÄ·½·¨³ö·¢£¬ÊµÏÖÁË·ÇAccess¸ ......
×ò
ÌìºÍanimatorÊÔÑéÁËһϣ¬°Ñdata.mdbÎļþ¸ÄÃûΪdata.aspÎļþºó·ÅÔÚwwwrootĿ¼ÀȻºóÔÚIEÖÐÊäÈëdata.asp·¾¶
ºó£¬·¢ÏÖIEÏÔʾһƬ¿Õ°×£¬ÓÒ¼ü->²ì¿´Ô´Îļþ£¬Ìø³ö¼Çʱ¾£¬½«ÄÚÈÝÁí´æΪ.mdbÎļþ£¬ÓÃACCESS´ò¿ª£¬·¢ÏÖÐèÒªÃÜÂ룬Ҳ¾ÍÊÇ˵ÖÁÉÙÎļþÍ·±»
ÆÆ»µ¡£
È»ºóÓÃFlashgetÊÔÑéÏÂÔØdata.aspÎļþ£¬²¢Áí´æΪdata.mdbÎÄ
¼þ£¬·¢ÏÖÓÃACCESS´ò¿ªÍêºÃÎÞË𣡿´À´£¬ºÃһЩ±à³ÌÈËÔ±ÔÚ¿ª·¢µÄʱºò¶¼ÈÏΪ£¬¸ÄÁËmdbºó׺Ϊasp¾ÍÄÜ·ÀÏÂÔصĸÅÄÊÇ´íµÄ£¡ºǫ́Êý¾Ý¿â±»ÏÂÔضÔÓÚ
Ò»¸öasp+accessµÄÍøÕ¾À´ËµÎÞÒÉÊÇÒ»³¡²Ò¾øÈËå¾µÄÔÖÄÑ¡£½ñÌìÕÒÁ˸÷·½µÄÎÄÕ£¬¹éÄÉÒ»ÏÂÓÐÒÔÏÂ9ÖÖ°ì·¨·ÀÖ¹Êý¾Ý¿â±»ÏÂÔØ(»¶Ó²¹³ä)¡£
1.·¢»ÓÄãµÄÏëÏóÁ¦ÐÞ¸ÄÊý¾Ý¿âÎļþÃû
²»ÓÃ˵£¬ÕâÊÇ×î×î͵ÀÁµÄ·½·¨£¬µ«ÊÇÈô¹¥»÷Õßͨ¹ýµÚÈý·½Í¾¾¶»ñµÃÁËÊý¾Ý¿âµÄ·¾¶£¬¾ÍÍæÍê
ÁË¡£±ÈÈç˵¹¥»÷Õß±¾À´Ö»ÄÜÄõ½listȨ£¬½á¹ûÒâÍâ¿´µ½ÁËÊý¾Ý¿â·¾¶£¬¾Í¿ÉÒÔ¹ÚÃáÌûʵذÑÊý¾Ý¿âÏÂÔØ»ØÈ¥Ñо¿ÁË¡£ÁíÍ⣬Êý¾ÝÎļþͨ³£´óС¶¼±È½Ï´ó£¬ÆðÔÙÒþ
±ÎµÄÎļþÃû¶¼Â÷²»ÁËÈË¡£¹Ê±£ÃÜÐÔΪ×îµÍ¡£
2.Êý¾Ý¿âÃûºó׺¸ÄΪASA¡¢ASPµÈ
´Ë·¨ÐëÅäºÏһЩҪ½øÐÐһЩÉèÖ㬷ñÔò¾Í»á³öÏÖ±¾ÎÄ¿ªÍ·µÄÄÇÖÖÇé¿ö¡£
(1)¶þ½øÖÆ×Ö¶ÎÌí¼Ó¡£
(2)ÔÚÕâ¸öÎļþÖмÓÈ룬I ......
ÔÚACCESS(2007)Êý¾Ý¿âÖУ¬ÓÐÕâÑùÒ»¸öÄ£ºý²éѯ£¬
select postId,postName,postType,left(postTime,10) as postTimes from PostInfo where postUser like '*ÖÜ·¼*'
ÔÚÊý¾Ý¿â²éѯºó½á¹ûÏÔʾÕýÈ·£¬¿ÉÊÇ·ÅÔÚÏîÄ¿µÄ´úÂëÖУ¬¾ÓÈ»²»ÏÔʾ²éѯµÄ½á¹û¿©¡£¼ì²éÁË°ëÌ춼ûÓз¢ÏÖ´íÎóÔÚÄÄÀ×îºó²ÅÖªµÀ£¬ÓеÄACCESS¾ÓÈ»²»ÈÏʶͨÅä·û*£¬ËùÒÔÖ»ºÃ»»³É%£¬½á¹û¾ÍºÃ¿©£¬ÎÒÕæÓôÃÆ¡£ ......
×î½üÔÚ×öAccessµÄÒ»¸öÏîÄ¿£¬×ÜÊÇĪÃûÆäÃîµÄÌáʾ£º“Insert Into Óï·¨´íÎ󔣬ÕâÑùµÄÐÅÏ¢×ܸøÈË´øÀ´ºÜ¶àÂé·³£¬ÓÐʱºòΪÁËÕâÑùÒ»¸ö´íÎóÒªÕҺþòÅÄܽâ¾öÎÊÌ⣬"Insert Into Óï·¨´íÎó"Õâ¸öÌáʾ±¾Éí°üº¬µÄÐÅÏ¢Á¿ºÜÉÙ£¬ÔÚ¸ú×Ù¶ÑÕ»ÖÐÓÐÕÒ²»µ½¸üÏêϸµÄÐÅÏ¢£¬ÎªÁ˱ÜÃâ´ó¼ÒÔÚ¿ª·¢µÄ¹ý³ÌÖÐÓöµ½Í¬ÑùµÄ´íÎóºÍÀ§ÈÅ¡£Í¨¹ý²éÕÒºÍÃþË÷°ÑÓпÉÄܳöÏÖÕâÖÖ´íÎóµÄ¿ÉÄÜ×ܽáһϺʹó¼ÒÒ»Æð·ÖÏí¡£
1.¹Ø¼ü×Ö£ºÈç¹ûÄãµÄÊý¾Ý¿âµÄ±íµÄÉè¼Æ°üº¬ÁËAccess°üº¬µÄ¹Ø¼ü×Ö£¬ÔòÔÚ²åÈëµÄʱºò»á³öÏÖ“Insert Into Óï·¨´íÎó”
ÀýÈ磺
string sqlText = String.Format("Insert into TestTable(Id,Order) values ({0},{1})",123,0);
ÕâÐÐÉÏÃæÕâÌõÓï¾äÊÇʧ°ÜµÄ£¬ÔÒòÊÇTestTable±íÖÐÓÐÒ»¸ö¹Ø¼ü×Ö"Order",½â¾ö°ì·¨£º
£¨1£©.½«Óï¾äÖеĹؼü×ÖÓÃ[order]´¦Àí¾Í¿ÉÒÔÁË¡£È磺
string sqlText = String.Format("Insert into TestTable(TestId,[Order]) values ({0},{1})",123,0);
(2).½«ËùÓеÄ×ֶζ¼ÓÃ[]À¨ÆðÀ´£¬ÕâÔÚÐí¶à´úÂëÉú³ÉÆ÷Öж¼²ÉÓÃÕâÖÖ·½Ê½À´½â¾ö¹Ø¼ü×ֵijåÍ»ÎÊÌâ¡£È磺
string sqlText = String.F ......
½ñÌìupdate accessÊý¾Ý¿âʱ£¬Ê¹ÓÃÁ˲ÎÊý»¯µÄ·½Ê½£¬½á¹û²»±¨´í£¬µ«ÊÇÊý¾ÝҲûÓиüС£¾¹ýgoogle·¢ÏÖaccessʹÓòÎÊý»¯Ê±£¬²ÎÊýλÖñØÐëºÍ¸³ÖµË³ÐòÏàͬ²ÅÐУ¬·ñÔò¸üÐÂʱ¾Í»á³öÏÖÊý¾ÝÎÞ·¨¸üе«ÊÇÒ²²»±¨´íµÄ¹ÖÏÖÏó¡£
ÀýÈç:update tablename set [a]=@a,[b]=@b where [id]=@id
ÄÇôÄãÔÚ¼Ó²ÎÊýʱ£¬Ò²±ØÐëÏȼÓ@a,ÔÙ¼Ó@b£¬×îºó¼Ó@id.Ò²¾ÍÊÇ˵±ØÐëÒª
cmd.Parameters.AddWithValue(“@a”,a);cmd.Parameters.AddWithValue(“@b”,b);cmd.Parameters.AddWithValue(“@id”,id);˳ÐòÈç¹û´íÁË£¬¾ÍÎÞ·¨¸üÐÂÁË¡£ÕâÒ»µãºÍsql server²»Ò»Ñù¡£ÔÚsql serverÖУ¬²»±Ø¹ØÐIJÎÊýÔö¼ÓµÄ˳Ðò¡£
ÒòΪaccessÔÚupdateʱ²ÎÊý´íλ²»»á±¨bug£¬Ö»ÊDz»¸üУ¬ËùÒÔÕâÒ»µãÔÚд³ÌÐòʱһ¶¨Òª×¢Òâ¡£ ......