Hi Everyone,
I am trying to write an MDL in C/C++ that should attach Meta-Data to Elements in an external MDB-Database.
I wrote already Code to make sure that the correct Database (DB) is attached, but now I have Problems how to attach the created MSLink to an element.
There is one function to write the Attributes into the DB and retrieve the MSLink:
Private int writeObjatt ( UInt32 *mslink, char *tableName, char *objidP, char *oclassP, char *ocodeP, char *icodeP, char *statusP ) { char insertStmt[MAXSTATEMENTLENGTH]; char dbColumns[5*TAGSTRINGVALLENGTH+10]; char dbValues[5*TAGSTRINGVALLENGTH+10]; int ret=-1, test1=-1; // Writing the column-names into a string sprintf(dbColumns, "objid, oclass, ocode, icode, status"); // writing the values into a string sprintf(dbValues, "'%s','%s','%s','%s','%s'", objidP, oclassP, ocodeP, icodeP, statusP); // writing the finlal SQL-Insert-Statement into a string sprintf(insertStmt, "insert into %s (%s) values (%s)", tableName, dbColumns, dbValues); fprintf(f_log, "\t(In tab2db_writeObjatt): Insert-Statement= '%s'\n", insertStmt); // Writing into Database test1 = mdlDB_addRowWithMslink(mslink, tableName, insertStmt); if(test1 == SUCCESS) ret=SUCCESS; return ret; }
Private int CallbackFunct ( ElementRef elR, void *callbackArg, // Structur with arguments for Callback-function ScanCriteriaP scP // Pointer to ScanCriteria-Object ) { int ret=SUCCESS; int test=-1, status=-1; int elType; // Element-Typ UInt32 mslink; // MSLink-Number CallbackArgStruct *data = (CallbackArgStruct*)callbackArg; MSElementP elP; EditElemHandle eh(elR, mdlScanCriteria_getModel(scP)); // Element-Handler char t_objidP[TAGSTRINGVALLENGTH], t_oclassP[TAGSTRINGVALLENGTH], t_ocodeP[TAGSTRINGVALLENGTH]; char t_icodeP[TAGSTRINGVALLENGTH], t_statusP[TAGSTRINGVALLENGTH]; // Checking Element-Type elType = eh.GetElementType(); // Pointer to element created from ElemeHandle elP = eh.GetElementP(); if(elType==CELL_HEADER_ELM || elType==LINE_ELM || elType==LINE_STRING_ELM || elType==LINE_STRING_ELM) { [...] // Retrieve Attribute-values from element // Writing Attributes into Database using the above mentioned function test = writeObjatt(&mslink, "objatt", t_objidP, t_oclassP, t_ocodeP, t_icodeP, t_statusP); //????? How to attach the MSLink to the MSElement ?????// // REPLACING the old element instead of rewriting in reason of different Size after MSLink-Attachment ?? status = ReplaceElement (elP); //??? if(test != SUCCESS) ret=-1; } return ret; }