Problem in inserting record C# Navision

int _tableNo = _cFrontDotNet.TableNo(“Item”);

int TableHandler = _cFrontDotNet.OpenTable(_tableNo);

int RecHandler = _cFrontDotNet.AllocRecord(TableHandler);

string NavDec1, NavDec2, NavDec3, NavDec4;

for (int icnt = 0; icnt < dgViewInsertRec.RowCount-1; icnt++)

{

NavDec1 = dgViewInsertRec[0, icnt].Value.ToString();

_cFrontDotNet.InitRecord(TableHandler, RecHandler);

_cFrontDotNet.BeginWriteTransaction();

_cFrontDotNet.SetFieldData(TableHandler, RecHandler,1,NavisionFieldType.Code,NavisionCode.Parse(NavDec1).GetBytes());

NavDec2 = dgViewInsertRec[1, icnt].Value.ToString();

_cFrontDotNet.SetFieldData(TableHandler, RecHandler, 2, NavisionFieldType.Text, NavisionText.Parse(NavDec2).GetBytes());

With the second SetFieldData it throws error “The field type is not correct, it must be type Text.”. I have already set it to Text.

Thanx

Regards,

Poonam J

I have got the solution of this problem myself. Its working now.

Regards,

Poonam

I never used CFront and I will never know if I will need.

Insert solution for future users [;)]

Actually it was a silly mistake that I was doing. Thts why I didn’t write about the solution.

The field type that I was defining for a particular field was not correct. Actually it was code type and I was passing Text Type and hence the error.

Regards,

Poonam Jha