ADO Connection exceeds the size of the string buffer

tinnertinner Member Posts: 5
Could someone help see why the code below would bring back the string buffer error when it tries to set the ADORecSet?

"The length of the text string exceeds the size of the string buffer."

I don't see how there's anyway it can exceed 1024, but maybe I'm missing something.

Name	            DataType	Subtype	Length
ADOConnection     Automation           'Microsoft ActiveX Data Objects 6.0 Library'.Connection	
ADORecSet          Automation           'Microsoft ActiveX Data Objects 6.0 Library'.Recordset	
ADOStream          Automation           'Microsoft ActiveX Data Objects 6.0 Library'.Stream	
ConnString           Text                    250
SQLString            Text                    1000
RecordsAffected   Text                    1
RSOption	            Integer		
FieldValue           Text                     100
SingleQuote         Text                    1

IF ISCLEAR(ADOConnection) THEN BEGIN
      IF NOT CREATE(ADOConnection) THEN BEGIN
      ERROR(Text001);
   END;
END;

IF ISCLEAR(ADORecSet) THEN BEGIN
      IF NOT CREATE(ADORecSet) THEN BEGIN
         ERROR(Text002);
   END;
END;

DatabaseName := 'NAV_TEST';

ConnString := 'Provider=SQLOLEDB.1;Integrated Security=SSPI;' +
                    'Persist Security Info=False;Initial Catalog='+ DatabaseName +';Data Source=SQLSERVER';

RecordsAffected := '';
RSOption := 0;

SQLString := 'SELECT No_, Description, [Vendor Item No_], [Net Weight], [Global Dimension 2 Code] ' +
             'FROM [Cronus Test$Item] ' +
             'WHERE (No_ = ' + SingleQuote + ItemNo + SingleQuote + ')';

ADOConnection.ConnectionString(ConnString);
ADOConnection.Open;
RecordsAffected := '';
RSOption := 0; 


ADORecSet := ADOConnection.Execute(SQLString,RecordsAffected,RSOption);

ADORecSet.MoveFirst;

FieldValue :=  ADORecSet.Fields.Item('Description').Value;

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    I don't know if this is relevant but I always use a variable of type Variant to pass the SQL statement:
    Name             DataType
    varSQLString     Variant
    [...]
    varSQLString := SQLString;
    [...]
    ADORecSet := ADOConnection.Execute(varSQLString,RecordsAffected,RSOption);
    [...]
    
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • tinnertinner Member Posts: 5
    I don't know if this is relevant but I always use a variable of type Variant to pass the SQL statement:
    Name             DataType
    varSQLString     Variant
    [...]
    varSQLString := SQLString;
    [...]
    ADORecSet := ADOConnection.Execute(varSQLString,RecordsAffected,RSOption);
    [...]
    
    Thanks, I gave it a shot, but no such luck...still getting the same error.
  • wizard_of_clausewizard_of_clause Member Posts: 6
    tinner wrote:
    Could someone help see why the code below would bring back the string buffer error when it tries to set the ADORecSet?

    "The length of the text string exceeds the size of the string buffer."

    I don't see how there's anyway it can exceed 1024, but maybe I'm missing something.

    In my experience this has nothing to do with the string you are passing to ADO. I wouldn't make any sense either.

    This error message indicates that NAV is trying to display something (buffer). What it tries to display in the case of an Automation object call is the error returned by same object. In your case, the SQL query failed at some point and ADO is reporting the fact. Usually the error would be displayed as reported, giving the developer/user a hint at where to look for causes. Every now and then however the error message it reports exceeds the 1024 characters limit for some ultimately unimportant reason.

    To summarize, don't waste your time looking for errors in NAV. Concentrate on your SQL query/batch.

    I know it's probably too late for the original poster, but I hope someone will find this helpful anyway.
    The difference between theory and practice is smaller in theory than it is in practice.
Sign In or Register to comment.