VB´´½¨ACCESSÊý¾Ý¿âÈ«½â
VB´´½¨ACCESSÊý¾Ý¿âÈ«½â ¶¯Ì¬´´½¨Êý¾Ý¿â¡¢´´½¨±í£¬´´½¨¼Ç¼ ADO¡¢ADOX2009Äê04ÔÂ20ÈÕ ÐÇÆÚÒ» 10:17ÕªÒª£º ±¾ÎIJûÊöÁËÔÚVB³ÌÐòÖÐÀûÓÃADO¶ÔÏó¶¯Ì¬´´½¨Êý¾Ý¿âºÍÊý¾Ý±íµÄ·½·¨£¬ÕâЩ·½·¨ÔÚ¿ª·¢VBÊý¾Ý¿âÓ¦ÓóÌÐòÖкÜÓÐʵÓüÛÖµ£¬Ëü¿ÉÒÔÌá¸ßÊý¾Ý¿â³ÌÐòÁé»îÐÔ¡£
¡¡¡¡¹Ø¼ü´Ê£ºÊý¾Ý¿â¡¢Êý¾Ý±í¡¢ADO¡¢ADOX
¡¡¡¡1: ÎÊÌâµÄÌá³ö
¡¡¡¡ÔÚVisual BasicÖУ¬³£ÓõÄÊý¾Ý·ÃÎʽӿÚÓÐÏÂÁÐÈýÖÖ£ºÊý¾Ý¿â·ÃÎʶÔÏó(DAO£¬Data Access Object)¡¢Ô¶³ÌÊý¾Ý¿â¶ÔÏó(RDO£¬Remote Data Object)ºÍActiveXÊý¾Ý¶ÔÏó(ADO£¬ActiveX Data Object )¡£Êý¾Ý¿â·ÃÎʼ¼ÊõÒ»Ö±ÔÚ²»¶Ï½ø²½£¬¶øÕâÈýÖÖ½Ó¿ÚµÄÿһÖÖ¶¼·Ö±ð´ú±íÁ˸ü¼ÊõµÄ²»Í¬·¢Õ¹½×¶Î¡£×îеÄÊÇADO£¬ËüÊDZÈRDOºÍDAO¸ü¼Ó¼òµ¥£¬È»¶ø¸ü¼ÓÁé»îµÄ¶ÔÏóÄ£ÐÍ¡£ÕýÒòÈç´Ë£¬Ô½À´Ô½¶àµÄÈËÔÚÓÃVB¿ª·¢Êý¾Ý¿âÈí¼þʱʹÓÃADO×÷ΪÊý¾Ý·ÃÎʽӿڡ£ÔÚ¿ª·¢¹ý³ÌÖУ¬ÎÒÃÇͨ³£µÄʹÓõķ½·¨ÊÇ£ºÏÈʹÓÃÊý¾Ý¿â¹ÜÀíϵͳ(ÀýÈ磺Microsoft Access)»òVBÖеĿÉÊÓ»¯Êý¾Ý¹ÜÀíÆ÷½¨Á¢ºÃÊý¾Ý¿âºÍÊý¾Ý±í½á¹¹£¬È»ºóÔÚ³ÌÐòÖÐͨ¹ýʹÓÃADODCÊý¾Ý¿â¿Ø¼þ»òÒýÓÃADO¶ÔÏóÓëÊý¾Ý¿âÖÐµÄ±í½¨Á¢Á¬½Ó£¬ÔÙͨ¹ýÊý¾Ý¿â¸ÐÖª¿Ø¼þ(ÀýÈ磺Îı¾¿ò¡¢DataGridµÈ)À´½øÐÐÊý¾Ý¿âµÄ¸÷ÖÖ²Ù×÷¡£ÔÚÕâÖÖ¿ª·¢¹ý³ÌÖУ¬ÎÒÃÇÓÐʱÐèÒªÃæ¶ÔÕâÑùÒ»¸öÎÊÌ⣺ÈçºÎÈÃÓû§ÔÚ³ÌÐòÔËÐйý³ÌÖж¯Ì¬µØ½¨Á¢×Ô¼ºËùÐèµÄÊý¾Ý¿âºÍÊý¾Ý±íÒÔÌá¸ß³ÌÐòµÄÁé»îÐÔÄØ£¿ÔÚ³ÌÐòÔËÐйý³ÌÖн¨Á¢×Ô¼ºËùÐèµÄÊý¾Ý¿âºÍÊý¾Ý±í£¬Æä±¾ÖʾÍÊÇÓôúÂë(»òÕß˵ͨ¹ý±à³Ì)À´½¨Á¢Êý¾Ý¿âºÍÊý¾Ý±í¡£ÖÚËùÖÜÖª£¬ÔÚFoxpro»òASP±à³ÌÖУ¬ÕâÊǺÜÈÝÒ×µÄÒ»¼þʼþ¡£ÄÇôÔÚVBÊý¾Ý¿â±à³ÌÖÐÓÖÊÇÔõÑùÀ´²Ù×÷µÄÄØ£¿ÔÚVBÊý¾Ý¿â±à³ÌÖУ¬Èç¹ûʹÓÃDAO×÷ΪÊý¾Ý¿â·ÃÎʽӿڼ¼Êõ£¬Ôò¿ÉÒÔÓÃCreateDatabase½áºÏCreateTableDef·½·¨À´ÊµÏÖ£¬Ä¿Ç°ÒÑÓв»ÉÙÊéºÍÔÓÖ¾¶¼½²µ½ÁËÕâÖÖ·½·¨£¬±¾ÎľͲ»ÔÙ½²ÊöÁË£»µ«ÄãÈç¹ûʹÓõÄÊÇ×îеÄÊý¾Ý¿â·ÃÎʽӿڼ¼ÊõADO£¬ÄãÈ´·¢ÏÖÄ¿Ç°µÄÊéºÍÔÓÖ¾ÉÏûÓÐÎÄÕ½²µ½ÈçºÎÓôúÂëÀ´½¨Á¢Êý¾Ý¿âºÍÊý¾Ý±íµÄ·½·¨£¬¿ÉÓÐʱÎÒÃǷdz£ÐèÒªÓõ½ÕâÖÖ·½·¨£¬ÏÂÃæÎÒÃǾÍÀ´½â¾öÕâ¸öÎÊÌâ¡£
¡¡¡¡2: ADOÓëADOX
¡¡¡¡ÎÒÃÇÏÈÀ´¶ÔADO ºÍADOX½øÐмòµ¥µÄÈÏʶ¡£ÔÚVB6ÖУ¬Ê¹ÓÃADO¿ª·¢Êý¾Ý¿âÓ¦ÓóÌÐòʱ£¬ÎÒÃÇÒªÒýÓöÔÏó¿â"Microsoft ActiveX Data Objects 2.5 Library"£¬ Õâ¸ö¶«Î÷µÄ¼ò³Æ¾ÍÊÇADO£¬ËüÊÇVB6Êý¾Ý¿â×îºËÐĵĶÔÏóȺ£¬Ò²ÊÇVBÊý¾Ý¿â¿ª·¢ÈËÔ±¾³£ËùÒýÓõĶÔÏó¿â£¬ÔÚVB6ÖÐÄã¿ÉÒÔ¿´µ½ËüµÄ¸÷ÖÖ°æ±¾£¬´Ó2.0°æµ½2.6°æ¶¼ÓУ¬ºÜ¶àÈ˶ÔËüÒѾºÜÊìϤ£¬ÔÚ´ËÎÒÃDz»ÔÙÏêϸ½éÉÜ¡£Èç¹ûÒªÔÚ³ÌÐòÔËÐйý³ÌÖд´½¨Êý¾
Ïà¹ØÎĵµ£º
ÈÃVB²ËÄñ×î¿ìд³ö×Ô¼ºµÄÍâ¹Ò.ͨɱËùÓÐÓÎÏ·.ºÇºÇ.
ÕâÄêÍ·,ÔÚÕâ¸öÂÛ̳ÀïÃæÒѾûÓÐʲô¼¼ÊõÌùÁË...ºÇºÇ~·¢Ò»Æª¾ªÌìµØ,Æü¹íÉñµÄÌû×Ó.µ±È»Õâ¸öÖ»ÊÇÄ£Äâ¼üÅ̵ÄÖÕ¼«Ä£Äâ.ºÇºÇ~
¼üÅÌÊÇÎÒÃÇʹÓüÆËã»úµÄÒ»¸öºÜÖØÒªµÄÊäÈëÉ豸ÁË£¬¼´Ê¹ÔÚÊó±ê´óÐÐÆäµÀµÄ½ñÌ죬ºÜ¶à³ÌÐòÒÀÈ»Àë²»¿ª¼üÅÌÀ´²Ù×÷¡£µ«ÊÇ ......
¾ßÌå²»¶à˵ÁË£¬Ö»Ìù³öÏà¹ØÔ´Âë~
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;
using System.Web;
/**//// <summary>
/// Ãû³Æ£ºaccessϵķÖÒ³·½°¸£¨·Âsql´æ´¢¹ý³Ì£©
/// ×÷Õߣºcncxz(³æ³æ)
/// blog£ºhttp://cncxz.cnblogs.com
/// ......
C#Á¬½ÓÁ¬½ÓAccess
Ê×ÏÈ¿´Ò»¸öÀý×Ó´úÂëƬ¶Ï:
³ÌÐò´úÂë:
--------------------------------------------------------------------------------
using System.Data;
using System.Data.OleDb;
......
string strConnection="Provider=Microsoft.Jet.OleDb.4.0;";
strConnection+=@"Data Source=C:\BegASPNET\Northwin ......
Ò»:
1 ÃÜÂëÊÇÊý¾Ý¿âÃÜÂ룺
ÉèÖÃÊý¾Ý¿âÃÜÂ룬´ò¿ªÃÜÂëΪ555´ò¿ªÊ±ÐèҪʹÓÃ
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\1.mdb;User ID=admin;Password=;Jet OLEDB:Database Password=555"
2 Óû§×飺
Óû§ÃûΪ admin ÃÜÂëΪ rr Óû§×éÎļþΪ c:\system.mdw£¬´ò¿ªÊ±ÐèҪʹÓÃ
"Provider=Microsoft.Jet.OLEDB.4.0 ......
²éѯÓï¾äÖ»ÒªÕâÑùд,¾Í¿ÉÒÔËæ»úÈ¡³ö¼Ç¼ÁË
SQL="Select top 6 * from Dv_bbs1 where isbest = 1 and layer = 1 order by newID() desc"
ÔÚACCESSÀï
SELECT top 15 id from tablename order by rnd(id)
SQL Server£º
Select TOP N * from TABLE Order By NewID()
Access£º
Select TOP N * from TABLE Order By Rnd(ID ......