ÓÐÈýÖÖ°ì·¨
µÚÒ»ÖÖÊÇÓÃaccessµÄJDBCÇý¶¯³ÌÐò£¬µ½http://industry.java.sun.com/products/jdbc/driversÕâ¸öÍøÕ¾ÉϲéÕÒ²¢ÏÂÔÚaccessµÄjdbcÇý¶¯³ÌÐò¡£
µÚ¶þ¸ö°ì·¨ÊÇÄãÓÃÏÂÃæµÄ´úÂëÊÔÊÔ
con = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=C:/data/Access/test1.mdb","dba","sql");
ºóÃæµÄ´úÂëÒ»Ñù¡£ÕâÑùÄã¾Í¿ÉÒÔ·ÃÎÊaccessÊý¾Ý¿âÁË¡£
µÚÈý¸öÊÇÓÃsunµÄjdbcodbcÇÅ£¬Õâ¸ö´ó¼ÒÓõĶàÁË£¬Ôڴ˾Ͳ»Ð´ÁË
Àý×ÓÒ»¡¢
/*
ÓÃJDBCÀ´Á¬½ÓÊý¾Ý¿âÓкÜÁ½ÖÖ·½Ê½,Èç
<1>JDBC:ODBC bridge,
<2>Ö±½ÓÁ¬½Ó·½Ê½.
µÚ¶þÖÖ·½Ê½ÓкܶàºÃ´¦,Ëü¿ÉÒÔ¶ÀÁ¢ÓÚÒÀÀµÓÚϵͳµÄodbcÊý¾ÝÔ´,
´æ´¢Êý¾ÝµÄdatabase¿ÉÒÔ×ÔÓɵØÒƶ¯
  ......
MS AccessÓï·¨´íÎóÐÅÏ¢
This short article deals with the following common MS Access-related error messages:
Syntax error (missing operator) in query expression 'field='some_partial_string'
Syntax error in INSERT INTO statement
Syntax error in UPDATE statement
Syntax error in from clause
Syntax error in WHERE clause
There are 4 main causes for these errors: using a Reserved Word for a field name; embedded spaces in field or table names; attempting to insert unescaped single quotes; and incorrectly delimited datatypes. There is a fifth cause, and that is a genuine syntax error resulting from a typo, or otherwise misconstructed SQL statement. Assuming that you are sure this fifth cause is not applicable in your case, here's how to deal with the other four.
Reserved Words and Embedded Spaces
The most common culprits among reserved words are NAME and PASSWORD, which at first glance appear to be perfectly reasonable choices for field names in, say, a User table. What can be mor ......
Ö±½Óͨ¹ýADO²Ù×÷AccessÊý¾Ý¿â
×÷Õß/Ðì¾°ÖÜ
ÏÂÔØÔ´´úÂë
ÎÒÔÚ¡¶VC֪ʶ¿âÔÚÏßÔÓÖ¾¡·µÚÊ®ËÄÆں͵ÚÊ®ÎåÆÚÉÏÔø·¢±íÁËÁ½ÆªÎÄÕ——“Ö±½Óͨ¹ýODBC¶Á¡¢Ð´Excel±í¸ñÎļþ”ºÍ“Ö±½Óͨ¹ýDAO¶Á¡¢Ð´AccessÎļþ”£¬ÏȺó¸ø´ó¼Ò½éÉÜÁËODBCºÍDAOÁ½ÖÖÊý¾Ý¿â·ÃÎʼ¼ÊõµÄ»ù±¾Ê¹Ó÷½·¨£¬Õâ´ÎÒª¸ø´ó¼Ò½éÉܵÄÊÇADOÊý¾Ý¿â·ÃÎʼ¼ÊõµÄʹÓ÷½·¨¡£ADO(Active Data Object£¬»î¶¯Êý¾Ý¶ÔÏó)ʵ¼ÊÉÏÊÇÒ»ÖÖ»ùÓÚCOM(×é¼þ¶ÔÏóÄ£ÐÍ)µÄ×Ô¶¯»¯½Ó¿Ú(IDispatch)¼¼Êõ£¬²¢ÒÔOLE DB(¶ÔÏóÁ¬½ÓºÍÏâÈëµÄÊý¾Ý¿â)Ϊ»ù´¡£¬¾¹ýOLE DB¾«ÐÄ°ü×°ºóµÄÊý¾Ý¿â·ÃÎʼ¼Êõ£¬ÀûÓÃËü¿ÉÒÔ¿ìËٵĴ´½¨Êý¾Ý¿âÓ¦ÓóÌÐò¡£ ADOÌṩÁËÒ»×é·Ç³£¼òµ¥£¬½«Ò»°ãͨÓõÄÊý¾Ý·ÃÎÊϸ½Ú½øÐзâ×°µÄ¶ÔÏó¡£ÓÉÓÚODBCÊý¾ÝÔ´Ò²ÌṩÁËÒ»°ãµÄOLE DB Privider£¬ËùÒÔADO²»½ö¿ÉÒÔÓ¦ÓÃ×ÔÉíµÄOLE DB Privider£¬¶øÇÒ»¹¿ÉÒÔÓ¦ÓÃËùÓеÄODBCÇý¶¯³ÌÐò¡£¹ØÓÚOLE DBºÍADOµÄÆäËüÏêϸÇé¿ö£¬¶ÁÕß¿ÉÒÔ×ÔÐвéÔÄÏà¹ØÊé¼®»òMSDN£¬ÕâÀï¾Í²»Ò»Ò»ËµÃ÷ÁË¡£ÈÃÎÒÃÇÖ±½Ó²½ÈëÖ÷Ì⣺ÈçºÎÕÆÎÕADOÕâÖÖÊý¾Ý¿â·ÃÎʼ¼Êõ¡£ADOµÄ²Ù×÷·½·¨ºÍÇ°Ãæ½²¹ýµÄDAOµÄ²Ù×÷Ôںܶ෽Ãæ´æÔÚÏàËÆÖ®´¦£¬ÔÚÕâÀ±ÊÕßΪÁ˸üÓÐЧµÄ˵Ã÷ËüµÄʹÓ÷½·¨£¬ÓÃVC6.0×öÁËÒ»¸öʾÀý³Ì ......
²¿·ÖÂÛ̳ÐÂÊÖÃÇû¾¯Ìè×Ô¼ºÂÛ̳Êý¾Ý¿â´æÔÚµÄΣÏÕ£¬ËùÒÔ»¹ÊÇ ¾ö¶¨ÒÔDvbbs7.0ΪÀý£¬½éÉÜÒ»ÏÂÈçºÎ±£»¤ºÃÄãµÄAccessÊý¾Ý¿â ¡£Ïл°ÐÝ˵£¬ÇëÍùÏ¿´£º
1¡¢¸øÄãµÄAccessÊý¾Ý¿â¼ÓÉÏÃÜÂë±£»¤£¨ÆäʵAccessÊý¾Ý¿â µÄÃÜÂë±£»¤·Ç³£´àÈõ£¬ÕâÀֻÊǸøËû¶à¼ÓÉÏÒ»°ÑËø¶øÒÑ£©¡£
a.´ò¿ªMicroSoft AccessÈí¼þ£¬ÊÇÓöÀÕ¼·½Ê½´ò¿ªÄãµÄDVÂÛ Ì³Êý¾Ý¿â£¨Êý¾Ý¿âĬÈÏλÖÃΪÂÛ̳¸ùĿ¼ÏµÄdata/dvbbs7.mdb £©¡£
b.ÉèÖÃÊý¾Ý¿âÃÜÂ룬AccessÈí¼þ²Ëµ¥Ï¹¤¾ß——¡µ°²È«— —¡µÉèÖÃÊý¾Ý¿âÃÜÂë¡£
2¡¢ÐÞ¸ÄÄãµÄÊý¾Ý¿âÃû³Æ¡£
¶¯ÍøÂÛ̳7.0Êý¾Ý¿âĬÈÏÃû³ÆΪDvbbs7.MDB£¬ÎªÁ˲»±»·Ç·¨ÏÂÔØ ÒÔ¼°¿ç¿âÁ¬½Ó£¬ËùÒÔÎÒÃÇÓ¦¸Ã°ÑÃû³Æ¸ÄΪÈçÏÂÀàËƵĸñʽ£º
#123data.asp
#&$%1*dv.asa
{ad}3¡¢ÐÞ¸ÄÄãÂÛ̳µÄconn.aspÎļþ¡£
1£©Ê¹ÓüÇʱ¾»òÆäËûÎı¾±à¼Èí¼þÀ´´ò¿ªconn.aspÎļþ£¬ ´ò¿ªºó£¬Ä㽫¿´µ½Èçϼ¸ÐдúÂ룺
’Ãâ·ÑÓû§µÚÒ»´ÎʹÓÃÇëÐ޸ı¾´¦Êý¾Ý¿âµØÖ·²¢ÏàÓ¦ÐÞ¸Ä dataĿ¼ÖÐÊý¾Ý¿âÃû³Æ£¬È罫dvbbs6.mdbÐÞ¸ÄΪ dvbbs6.asp
Db = "data/dvbbs7.mdb"
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(db)
2£©°ÑDb = "data/dvbbs7.mdb"ÕâÒ»ÐÐÀïÃæµ ......
Microsoft Jet OLE DB 4.0
Standard security:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;User Id=admin;Password=;
With database password:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDB:Database Password=MyDbPassword;
Workgroup (system database):
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDB:System Database=system.mdw;
Workgroup (system database) specifying username and password:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDB:System Database=system.mdw;User ID=myUsername;Password=myPassword;
DataDirectory functionality:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\myDatabase.mdb;User Id=admin;Password=;
.NET Framework Data Provider for OLE DB
Bridging to Jet OLE DB 4.0:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;User Id=admin;Password=;
Microsoft Access ODBC Driver
Standard Security:
Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabas ......
Ê×ÏÈ´ò¿ªSQL Server Management Studio£¬½¨Á¢Ò»¸öÊý¾Ý¿â£¬½¨Á¢ºÃÊý¾Ý¿âºóÑ¡ÔñÄãµÄÊý¾Ý¿âÃû£¬ÓÒ¼ü--ÈÎÎñ--µ¼ÈëÊý¾Ý¿â
´ò¿ªSQLµ¼ÈëºÍµ¼³öÏòµ¼--ÏÂÒ»²½--Êý¾ÝÔ´Ñ¡Ôñ£¨Microsoft Access£©--Ñ¡ÔñÄãµÄACCESSÊý¾Ý¿âÈ»ºóÏÂÒ»²½
¡¡
¹Ø¼üµÄÒ»²½ÔÚ“Ñ¡ÔñÔ´±íºÍÔ´ÊÓͼ”ÕâÀѡÔñ±í--±à¼Ó³Éä--Ñ¡Ôñ“ÆôÓñêʶ²åÈ딡£
¡¡
ÔÚÕâÀïÿһ¸ö±í¶¼Òªµ¥¶À±à¼Ó³É䣬ËùÓÐ±í¶¼ÆôÓñêʶ²åÈëÈ»ºóÏÂÒ»²½¡£
µ¼ÈëÍê³ÉOK£¡ ......
Ê×ÏÈ´ò¿ªSQL Server Management Studio£¬½¨Á¢Ò»¸öÊý¾Ý¿â£¬½¨Á¢ºÃÊý¾Ý¿âºóÑ¡ÔñÄãµÄÊý¾Ý¿âÃû£¬ÓÒ¼ü--ÈÎÎñ--µ¼ÈëÊý¾Ý¿â
´ò¿ªSQLµ¼ÈëºÍµ¼³öÏòµ¼--ÏÂÒ»²½--Êý¾ÝÔ´Ñ¡Ôñ£¨Microsoft Access£©--Ñ¡ÔñÄãµÄACCESSÊý¾Ý¿âÈ»ºóÏÂÒ»²½
¡¡
¹Ø¼üµÄÒ»²½ÔÚ“Ñ¡ÔñÔ´±íºÍÔ´ÊÓͼ”ÕâÀѡÔñ±í--±à¼Ó³Éä--Ñ¡Ôñ“ÆôÓñêʶ²åÈ딡£
¡¡
ÔÚÕâÀïÿһ¸ö±í¶¼Òªµ¥¶À±à¼Ó³É䣬ËùÓÐ±í¶¼ÆôÓñêʶ²åÈëÈ»ºóÏÂÒ»²½¡£
µ¼ÈëÍê³ÉOK£¡ ......