Using Comobj unit for insert new record into ACCOUNT S/W (Commercial Program) lazarus / 34-Windows ---------------------------------------------------------------------- cjbs · 2015-12-14 09:13 I'm trying a simply way insert data into SQL Account via ComObj. Lazarus version 1.4.4, FPC version: 2.6.4, SVN Revision: 49931, i386-win32/win64 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses ... comobj; procedure TForm1.Button1Click(Sender: TObject);var o, B, M: Variant;    sDesc: string;begin  sDesc := 'ABC agent name';  o := CreateOleObject('SQLAcc.BizApp');  B := o.BizObjects.Find('AGENT');  M := B.DataSets.Find('MainDataSet');  B.New;  M.FindField('Code').AsString := 'ABC-AGENT';  M.FindField('Description').AsString := QuotedStr(sDesc);     // get this result: ??????    (INCORRECT)  //M.FindField('Description').AsString := 'ABC agent name';  <------ change this line and replace previous, work very well, result get from ACCOUNT S/W: ABC agent name (CORRECT)  B.Save;end; Any one know the problem? please help. P/S: it work very well in my friend's Delphi XE7. CJ ---------------------------------------------------------------------- marcov · 2015-12-14 10:24 try:  M.FindField('Description').AsString := widestring(QuotedStr(sDesc)); ---------------------------------------------------------------------- cjbs · 2015-12-14 12:05 Thanks marcov! It work very well! ---------------------------------------------------------------------- marcov · 2015-12-14 12:53 So probably the bit is that D2009+ convert string (which is unicodestring under the hood) to widestring when assigning to a variant. FPC and (probably) delphi versions before D2009, string=ansistring, and gets converted to ansistring in the variant, and COM doesn't know that. In theory, the original code should work in $mode delphiunicode :-) ---------------------------------------------------------------------- cjbs · 2015-12-14 13:39 Yes, but tried in FPC 3.0.0 (latest version) , same with FPC ver 2.6.4. still using ansistring. Anyway, happy with the lazarus.