Search code examples
adovisioadodbrecordset

Visio RecordSet - set row datatype to hyperlink from code not in designer


I want to set the following in codebehind:

Visio 2010 -> External Data -> Column settings -> Types and Units -> Hyperlink Checkbox

How do I set this Hyperlink flag on a self created adbo recordset?

object oMissing = System.Reflection.Missing.Value;
ADODB.Recordset rs = new Recordset();
rs.Fields.Append("DocId", DataTypeEnum.adVariant);
rs.Fields.Append("Title", DataTypeEnum.adVarChar, 255, FieldAttributeEnum.adFldIsNullable);
rs.Fields.Append("Link", DataTypeEnum.adVarChar, 4000, FieldAttributeEnum.adFldIsNullable);
rs.Open(Type.Missing, Type.Missing, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockBatchOptimistic);
rs.AddNew(oMissing, oMissing);
rs.Fields["DocId"].Value = doc.DocumentID.ToString();
rs.Fields["Title"].Value = doc.Title;
rs.Fields["Link"].Value = doc.Link;

I though FieldAttributeEnum.adFldIsRowURL would be Ok, but if i set this I'm getting a COMException which says the Arguments are from the wrong type.

Any ideas? Regards, float


Solution

  • You need to use the DataColumn.SetProperty method. see http://msdn.microsoft.com/en-us/library/office/ff766436(v=office.15).aspx