How to attach a MSLink to an Element

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;
  }
I thought, that this would write the given Attributes into the DB and that I 'only' would have to attach this MSLink to an element. (The return-value from this function Shows 'SUCCESS' and the values are correctly written into the DB!). (There is an 'mscatalog' table defined in the DB and as well another table <tableName> that contains apart of the 'mslink'-column 5 other columns, defined as Texts[TAGSTRINGVALLENGTH]).
The Elements for which the Meta-data should be attached are handled in a Callback-function (from 'mdlScanCriteria_setElemRefCallback') that is shown below:
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;
  }

So my Problem is, how I can attach the created MSLink to the Element it belongs to and how do I have to rewrite/replace it afterwards!
I tried to figure it out from the database-example 'gis.ma', but it seems to do something different in the sub-function 'gis_writeParcel', therefore I couldn't solve my Problem.
Many thanks for your help in advance,
Ines Wieland