Options

C/Front .NET - insert a new record

TrixzTrixz Member Posts: 21
Hi

Have problems when inserting a new record in C# code

Code:

tableHandle = cFront.OpenTable(50000);
recordHandle = cFront.AllocRecord(tableHandle);
cFront.BeginWriteTransaction();
cFront.LockTable(tableHandle, NavisionTableLockMode.LockWait);
cFront.InitRecord(tableHandle, recordHandle);
cFront.BeginWriteTransaction();
cFront.SetFieldData(tableHandle, recordHandle, 1, NavisionFieldType.Decimal, NavisionDecimal.Parse("2").GetBytes());
if (cFront.InsertRecord(tableHandle, recordHandle))
{
// if code
}
else
{
// else code
}
cFront.EndWriteTransaction();
cFront.FreeRecord(recordHandle);
cFront.CloseTable(tableHandle);


I also have a open/close connection to database

Everything works fine. I see the new record when I look in navision, but as soon as I close the database (it's ok to close record, table, company) the record disapears!
There is no errors or anything.

I have looked inte the sample application that comes with c/front but I can't seem to find anything useful.

Is there any function I have missed calling so that the records will stay?



I have also a modify/update function that works fine, even when the database is closed.

Comments

  • TrixzTrixz Member Posts: 21
    Somewhere in my code there was some kind of error. Did a rewrite and it worked fine.
  • SteveOSteveO Member Posts: 164
    I wonder if it's because you had 2x BeginWriteTransaction() but only 1x EndWriteTransaction()?

    At least it's working now!! :)
    This isn't a signature, I type this at the bottom of every message
Sign In or Register to comment.