/// <summary> /// 将dr转变到路径实体。 /// </summary> /// <param name="dr"></param> /// <returns>路径实体。</returns> private static PathInfo ConvertToPathInfo(IDataRecord dr) { var obj = new PathInfo(); obj.LastPath = dr["LastPath"].ToString(); return obj; }
public override bool Insert(PathInfo obj) { var sqlStatement = "Insert Into Path ([LastPath]) Values (@LastPath)"; var parms = new[] { new OleDbParameter("@LastPath",OleDbType.VarWChar,255){Value = obj.LastPath}, }; using (var conn = new OleDbConnection(this.ConnectionString)) { conn.Open(); var trans = conn.BeginTransaction(); try { AccessHelper.ExecuteNonQuery(trans, sqlStatement, parms); trans.Commit(); return true; } catch (Exception ex) { trans.Rollback(); Logger.Error(ex.Message, ex); return false; } finally { conn.Close(); } } }