Hallo
1. FindRecords()
I also have the FindRecords() Problem and as Arkej found out, it could be fixed by changing ...
// setup our index range
if (rows < 0)
{
this.SetUpperLimit();
}
if (rows > 0)
{
this.SetLowerLimit();
}
... to ...
// setup our index range
if (rows < 0)
{
this.SetLowerLimit();
}
if (rows > 0)
{
this.SetUpperLimit();
}
... of Move(int rows) function in Cursor.cs.
2. EditRecord Access after FindRecords()
Furthermore there is a minor Problem that it is possible to access the EditRecord, allthough the position of the cursor is out of range after a FindRecord() call. To fix the Problem I have to make some change here and there.
At first i added a private bool inserting field (like the exisiting updating, which keeps track if the cursor is in insert or update mode) which I only set at BeginEditForInsert() to know if the cursor is in insert mode and which is set to false, nearly everywhere where updating is set to false except in Delete() because the "updating = false" there is unnecessary, I think.
Than I changed Cursor.Checkrecord() to ...
/// <summary>
/// Checks the record.
/// </summary>
/// <param name="grbit">The optional grbit.</param>
/// <exception cref="EsentNoCurrentRecordException">
/// Thrown when the cursor is not on a record if not an insert of EditRecord.
/// </exception>
internal void CheckRecord(RetrieveColumnGrbit grbit = RetrieveColumnGrbit.None)
{
lock (this.isamSession)
{
if ((grbit & RetrieveColumnGrbit.RetrieveCopy) == 0 || ((grbit & RetrieveColumnGrbit.RetrieveCopy) != 0 & !inserting))
{
if (this.outOfRange)
{
throw new EsentNoCurrentRecordException();
}
}
}
}
At last I had to do the following changes in ColumnAccessor:
SizeOf(Columnid columnid, int index):
and
RetrieveColumn(JET_COLUMNID columnid, JET_coltyp coltyp, bool isAscii, int index)
//if ((this.grbit & RetrieveColumnGrbit.RetrieveCopy) == 0)
//{
// this.cursor.CheckRecord();
//}
this.cursor.CheckRecord(this.grbit);
SetColumn(JET_COLUMNID columnid, JET_coltyp coltyp, bool isAscii, int index, object obj)
this.cursor.CheckRecord(this.grbit);
if ((this.grbit & RetrieveColumnGrbit.RetrieveCopy) == 0)
{
//this.cursor.CheckRecord();
throw new InvalidOperationException("You may only update fields through Cursor.EditRecord.");
}
3. BeginEditForUpdate after FindRecords()
For consistency there should also be a CheckRecord() call in Cursor.BeginEditForUpdate() as in GetFields(), Position and Location. For now it is possible to issue BeginEditForUpdate() without an Exception after a FindRecord() call, allthough "out of range" at the "before first" position.
4. SystemParameters.AlternateDatabaseRecoveryPath
Martin, maybe ist is possible to add the AlternateDatabaseRecoveryPath to SystemParameters to allow to open a relocated (moved/copied) ESE database!?
/// <summary>
/// This parameter can be used to force crash recovery or a restore operation to look for the databases referenced in the transaction log in the specified folder.
/// </summary>
public string AlternateDatabaseRecoveryPath
{
get
{
int ignored = 0;
string val;
Api.JetGetSystemParameter(this.instance.Inst, JET_SESID.Nil, Server2003Param.AlternateDatabaseRecoveryPath, ref ignored, out val, 1024);
return val;
}
set
{
Api.JetSetSystemParameter(this.instance.Inst, JET_SESID.Nil, Server2003Param.AlternateDatabaseRecoveryPath, 0, value);
}
}
Kind Regards,
Tom