¼¸ÄêǰдµÄÒ»¸ö access ·ÃÎÊÀà dbutils
using System;
using System.Data;
using System.Xml;
using System.Data.OleDb ;
using System.Collections;
namespace ePhoto.AccessDAL
{
/// <summary>
/// DBUtil ²Ù×÷AccessÊý¾Ý¿â
/// </summary>
public class DBUtil
{
private Hashtable parmCache = Hashtable.Synchronized(new Hashtable()); //»º´æÓû§²ÎÊý
private static string path = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
System.Web.HttpContext.Current.Server.MapPath("")+"\\"+System.Configuration.ConfigurationSettings.AppSettings["AccessDataBase"] ; //Access Êý¾Ý¿âÎļþµØÖ·
/// <summary>
/// Ö´Ðе¥Ïò²Ù×÷£¬·µ»ØÊý¾Ý¿âÊÜÓ°ÏìµÄÐÐÊýʹÓÃĬÈÏÁ¬½Ó£¬ Ö´ÐÐSQLÓï¾ä£¬½ö½ö·µ»ØÊý¾Ý¿âÊÜÓ°ÏìÐÐÊý¡£
/// ËùÐè²ÎÊý£ºÃüÁîÎı¾£¬²ÎÊýÁÐ±í¡£
/// </summary>
/// <param name="cmdText">ÃüÁîÎı¾</param>
/// <param name="cmdParms">²ÎÊýÁбí</param>
/// <returns></returns>
public static int ExecuteNonQuery(string cmdText ,params OleDbParameter[] cmdParams)
{
OleDbCommand cmd = new OleDbCommand();
using(OleDbConnection conn = new OleDbConnection(path))
{
PrepareCommand(cmd,conn,null,CommandType.Text,cmdText,cmdParams);
int val = cmd.ExecuteNonQuery();
cmd.Dispose();
conn.Dispose();
return val ;
}
}
/// <summary>
/// Ö´ÐÐÒ»¸ösql²éѯÓï¾ä£¬·µ»ØDataReader¶ÔÏó¡£Ê¹ÓÃĬÈÏÁ¬½Ó¡£
/// ËùÐè²ÎÊý£ºÃüÁîÎı¾£¬²ÎÊýÁÐ±í¡£
/// </summary>
/// <param name="cmdText"></param>
/// <param name="cmdParms"></param>
/// <returns></returns>
public static OleDbDataReader ExecuteReader(string cmdText,params OleDbParameter[] cmdParms)
{
OleDbCommand cmd = new OleDbCommand();
OleDbConnection conn = new OleDbConnection(path);
try
{
PrepareCommand(cmd,conn,null,CommandType.Text,cmdText,cmdParms);
OleDbDataReader read = cmd.ExecuteReader(CommandBehavior.CloseConnection);
cmd.Parameters.Clear();
return read ;
}
Ïà¹ØÎĵµ£º
Ö±½Óͨ¹ýADO²Ù×÷AccessÊý¾Ý¿â
×÷Õß/Ðì¾°ÖÜ
ÏÂÔØÔ´´úÂë
ÎÒÔÚ¡¶VC֪ʶ¿âÔÚÏßÔÓÖ¾¡·µÚÊ®ËÄÆÚºÍµÚÊ®ÎåÆÚÉÏÔø·¢±íÁËÁ½ÆªÎÄÕ——“Ö±½Óͨ¹ýODBC¶Á¡¢Ð´Excel±í¸ñÎļþ”ºÍ“Ö±½Óͨ¹ýDAO¶Á¡¢Ð´AccessÎļþ”£¬ÏÈºó¸ø´ó¼Ò½éÉÜÁËODBCºÍDAOÁ½ÖÖÊý¾Ý¿â·ÃÎʼ¼ÊõµÄ»ù±¾Ê¹Ó÷½·¨£¬Õâ´Î ......
Ê×ÏÈ´ò¿ªSQL Server Management Studio£¬½¨Á¢Ò»¸öÊý¾Ý¿â£¬½¨Á¢ºÃÊý¾Ý¿âºóÑ¡ÔñÄãµÄÊý¾Ý¿âÃû£¬ÓÒ¼ü--ÈÎÎñ--µ¼ÈëÊý¾Ý¿â
´ò¿ªSQLµ¼ÈëºÍµ¼³öÏòµ¼--ÏÂÒ»²½--Êý¾ÝÔ´Ñ¡Ôñ£¨Microsoft Access£©--Ñ¡ÔñÄãµÄACCESSÊý¾Ý¿âÈ»ºóÏÂÒ»²½
¡¡
¹Ø¼üµÄÒ»²½ÔÚ“Ñ¡ÔñÔ´±íºÍÔ´ÊÓͼ”ÕâÀѡÔñ±í--±à¼Ó³Éä--Ñ¡ ......
ÔÚWin7ϰ²×°ÍêFoxmail6.5£¬Í˳ö³ÌÐò²¢ÖØÐÂÆô¶¯Foxmailºó³öÏÖÈçÏ´íÎó£º
Access violation at address 007CC4B1 in module 'Foxmail.exe'. Read of address 00000014.
µ¼ÖÂFoxmail²»ÄÜÆô¶¯£¬µã»÷È·¶¨ºóÈԻ᲻¶Ï³öÏÖÀàËÆ´íÎóÌáʾ¡£
Õâ¿ÉÄÜÊÇFoxmailÔÚWin7 ......
pos25 = find (coll.begin(), coll.end(), //range
25); //value
pos35 = find (coll.begin(), pos25, //range
35); //value
if (pos35 != pos25) {
/*pos35 is in front of pos25
*so, only [pos35,pos25) is valid
*/
...
}
else {
pos35 = find (pos25, coll.end ......
ACCESSµÄ´æ´¢¹ý³Ì´´½¨ÓëÖ´ÐÐ
´´½¨£º
ÔÚAccess×ÔÉíµÄ°ïÖúÖп´µ½ÁËCreate ProcedureÓï¾ä¡£
²âÊÔÁËÀϰëÌ죬ÖÕÓÚ·¢ÏÖÁ˾÷ÇÏ£º
±ØÐëʹÓÃOleDbÁ¬½Ó²ÅÄÜʹÓÃCreate ProcedureÓï¾ä¡£
ODBCÁ¬½Ó²»Ö§³Ö¸ÃÓï¾ä£¬ÌáʾCreate TableÓï·¨´íÎó¡£
´´½¨ÁË´æ´¢¹ý³Ìºó£¬Ê¹ÓÃOffice Access¹¤¾ß´ò¿ªÊý¾Ý¿â£¬ÔÚ“¶ÔÏó - ²éѯ”ÖÐÄ ......