TempDB error when calling linkPhysicalTableInstance

I got this when using a TempDB table in a form as a datasource: "Cannot execute the required database operation.The method is only applicable to TempDB table variables that are not linked to existing physical table instance.".

Of course, I was really writing to the table records after the form was completely displayed (let's say when hitting a button). After some tests I realized that the datasource's TempDB table was not properly linked to its SQL tempdb table (or something in that area). So, if I called one time insert on the table buffer in the init() after its super(), thing would work just fine.
So, to fix this:

void init()
{
    ...
    super();
    ...
    tempDBBuffer.doinsert();
    delete_from tempDBBuffer;
    formDS.lynkPhysicalTableInstance(tempDBBuffer);
    ...
}

2 comments:

  1. Nice post, Lulian!
    PS. There is a typo in your code example. It says "lync" and not "link". :-)

    ReplyDelete
  2. Thanks for your post. I was scratching my head to find a solution for this problem until I googled your post.

    ReplyDelete