¼Ü¹¹B/SËÄ DALFactory Êý¾Ý·ÃÎʲã Data Access Layer
2008-04-10 09:45 //*******FactoryManage.cs using System;
using System.Reflection;
using System.Configuration;
using CoalTraffic.IDAL; namespace CoalTraffic.DALFactory
{
/// <summary>
/// ³éÏ󹤳§Ä£Ê½´´½¨DAL¡£
/// web.config ÐèÒª¼ÓÈëÅäÖãº(ÀûÓù¤³§Ä£Ê½+·´Éä»úÖÆ+»º´æ»úÖÆ,ʵÏÖ¶¯Ì¬´´½¨²»Í¬µÄÊý¾Ý²ã¶ÔÏó½Ó¿Ú)
/// DataCacheÀàÔÚµ¼³ö´úÂëµÄÎļþ¼ÐÀï
/// ¿ÉÒÔ°ÑËùÓÐDALÀàµÄ´´½¨·ÅÔÚÕâ¸öDataAccessÀàÀï
/// <appSettings>
/// <add key="DAL" value="LiTianPing.SQLServerDAL" /> (ÕâÀïµÄÃüÃû¿Õ¼ä¸ù¾Ýʵ¼ÊÇé¿ö¸ü¸ÄΪ×Ô¼ºÏîÄ¿µÄÃüÃû¿Õ¼ä)
/// </appSettings>
/// </summary>
public sealed class DataAccess
{
private static readonly string path = System.Configuration.ConfigurationManager.AppSettings["DAL"]; #region CreateObject //²»Ê¹Óûº´æ
private static object CreateObjectNoCache(string path, string CacheKey)
{
try
{
object objType = Assembly.Load(path).CreateInstance(CacheKey);
return objType;
}
catch (Exception ex)
Ïà¹ØÎĵµ£º
¼´Ê¹ÎÒ½«Êý¾Ý¿â·ÅÔÚÏîÄ¿ÄÚ½¨µÄÎļþ¼ÐdbÏ£¬¿ÉÊǽøÐд洢²Ù×÷µÄʱºò£¬Êý¾Ý±íûÓÐÈκα仯¡£ºóÀ´·¢ÏÖ´¢´æ¸Ä±ä·¢ÉúÔÚbin\\debug\\dbĿ¼ÏµÄÊý¾Ý¿âÖУ¬Õâ¸öÊý¾Ý¿âÊÇÔÚ³ÌÐòÔËÐÐʱ×Ô¶¯¸´ÖƹýÈ¥µÄ£¬¿ÉÊÇΪʲô´æ´¢±ä»¯Ã»Óз´Ó¦µ½ÍâÃæÏîÄ¿ÄÚµÄÊý¾Ý¿âdbÏÂÄØ£¿ÎÒÏëÁ¬½Ó×Ö·û´®ÖÐdatasourceÖеÄdatadirectory´æÔÚһЩÐþ»ú£¬ÓÚÊÇÎÒÕÒµ½Ò ......
PBÖÐÁ¬½ÓAccessÊý¾Ý¿âµÄÈýÖÖ·½·¨
·½Ê½Ò»£º
SQLCA.DBMS = "ODBC"
SQLCA.AutoCommit = False
SQLCA.DBParm = "ConnectString='driver=Microsoft Access Driver (*.mdb);DBQ=c:\foodmart.mdb'"
CONNECT;
IF SQLCA.SQLCode <> 0 THEN
MessageBo ......
ÈÕÆÚ/ʱ¼ä
CDate ½«×Ö·û´®×ª»¯³ÉΪÈÕÆÚ select CDate("2005/4/5")
Date ·µ»Øµ±Ç°ÈÕÆÚ
DateAdd ½«Ö¸¶¨ÈÕÆÚ¼ÓÉÏij¸öÈÕÆÚselect dateAdd("d",30,Date())½«µ±Ç°ÈÕÆÚ¼ÓÉÏ30Ìì,ÆäÖÐd¿ÉÒÔ»»Îªyyyy»òHµÈ
DateDiff ÅжÏÁ½¸öÈÕÆÚÖ®¼äµÄ¼ä¸ô select DateDiff("d","2006-5-1& ......
1£¬´ò¿ª”¿ØÖÆÃæ°å“Ï”¹ÜÀí¹¤¾ß“ÖеĔÊý¾Ý¿âÔ´“£»
2£¬°´”Ìí¼Ó“Ìí¼ÓÒ»¸öеÄÊý¾ÝÔ´£¬ÔÚÑ¡ÔñÀ¸ÀïÑ¡“Driver do microsoft Access (*.mdb)”£¬Íê³Éºó½«³öÏÖÒ»¸ö¿ò£¬ÔÚ“Êý¾Ý¿âÔ´”ÀïÃæÊäÈëÄãÏëдµÄÃû³Æ£¬ÎÒÈ¡Ãû½Ð“ABC”£¬ËµÃ÷²»ÐèÒªÌ½Ó×Å ......