示例#1
0
 /// <summary>
 /// 测试MDB数据库链接
 /// </summary>
 /// <param name="MDB_PATH">数据库文件路径</param>
 /// <param name="Message">异常信息</param>
 /// <returns></returns>
 public static bool TestAccessConn(string MDB_PATH, ref string Message)
 {
     try
     {
         string connectingString       = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + MDB_PATH;// CM.Map.Config.GetConfigValue("MDB_Path");
         CM.Map.DatabaseOledb acc_conn = new DatabaseOledb(connectingString);
         if (acc_conn.Conn.State == ConnectionState.Closed)
         {
             try
             {
                 acc_conn.Open();
                 Message = "连接成功";
                 return(true);
             }
             catch (Exception ex)
             {
                 throw ex;
             }
             finally
             {
                 //Close DataBase
                 //关闭数据库连接
                 acc_conn.Close();
             }
         }
         Message = "未知原因";
         return(false);
     }
     catch (Exception ex)
     {
         CM.Map.Log.WriteLog("TestAccessConn()错误>>>>" + ex.Message);
         throw ex;
     }
 }
示例#2
0
        /// <summary>
        /// 判断数据库里面的记录与图层中是否完全一致
        /// </summary>
        /// <param name="solutionName">命名规则名</param>
        /// <param name="inputAtt">图层信息</param>
        /// <param name="strWhere">查询条件</param>
        /// <param name="strAccessPath">access数据库路径</param>
        /// <param name="strTableName">相关表名</param>
        /// <param name="keyValue">对应数据的关键字值</param>
        /// <returns></returns>
        public static bool CompareFeatureCK(string strKey, string strAccessPath)
        {
            try
            {
                DatabaseOledb db = new DatabaseOledb();
                db.Open();
                string    accSQL   = "select * from 采矿申请登记 where CK_GUID = '" + strKey + "'";
                DataTable dtAccess = db.GetDataSet(accSQL).Tables[0];
                db.Close();

                DataTable dtFeature = dtAccess;
                //DataTable dtFeature = f.GetLayerAttNew("两矿", "layerShortName=CKSQDJ", "CK_GUID", "CK_GUID", 10, 1, strKey, "").Tables[0];
                bool bSuccess = (dtAccess == dtFeature);
                return(bSuccess);
                //bool bSuccess=(drData==drFeature);
                //return bSuccess;
            }
            catch (Exception ex)
            {
                Log.WriteLog(ex.Message);
                throw ex;
            }
        }