Creating a Table in code

Hey, I’m doing a data migration from an SQL database into a Native Navision 370 database. I want to create all the SQL tables and fields in Navision. Im using the sysobjects table in the SQL database to get the table names of all tables in the db, but am struggling to create them in navision. Here is an extract of code: IF NOT RS.EOF THEN REPEAT _ObjectRec.INIT; _ObjectRec.Type := _ObjectRec.Type::Table; _ObjectRec.ID := "_TableNo."; // _ObjectRec.Name := COPYSTR(GetTextField2('name', RS),1, MAXSTRLEN(_FieldsRec.TableName)); _ObjectRec."Version List" := 'System Created for Migration'; _ObjectRec.INSERT(TRUE); "_TableNo." := "_TableNo." + 1; RS.MoveNext; UNTIL RS.EOF; The table will create but the blob is empty and I can not design the table or compile it (says the table is empty). I’ve tried using the Field table to create a primary key inside the table, but again it errors. I’m sure I did this a few years ago and can’t think what is wrong. Can you help? Regards, Alex

Hi! Maybe you could create a simple template table - the old-fashioned way using the Object Designer - with just one field. Now, create a little program to export the “BLOB Reference” of that table (from Object Table) using the the BLOB.EXPORT method. Finally, add some code to your function to import this template BLOB reference by BLOB.IMPORT method … Have not tried, maybe that works … Regards,

Another option could be to create an Object-Text-File containing all table- and field-information; than import this file via “Object Designer” and compile the new objects …

Thanks guys, I decided to stop wasting time with this and just built a text file with the 250 tables and an integer key. The fields can dynamically be created using the Record Set so it will still save alot of time (as long as we can map the SQL types correctly!). If you do have the solution for the original problem I’d still like to know. Alex.