Jun 24, 2011 at 4:06 PM

Can someone please explain what I'm doing wrong?

When I read SPSS files, it reads numeric variables fine, but always fails to read string variables with the following error:

SPSS function spssGetValueChar returned error code SPSS_BUFFER_SHORT

I'm not doing anything unusal that I can tell:

object s = doc.Cases[index].GetDBValue(VariableName);

Jul 11, 2011 at 5:45 PM
Edited Jul 11, 2011 at 5:45 PM

I am having the same problem and have found that it happens only with strings that are over 255 characters.

The problem occurs whether using GetDBValue (as John has above) or ToDataFile() as below:

DataTable dTable = spssDoc.Cases.ToDataTable();

Perhaps this problem is related to the closed work item "string variable max length can't exceed 255 characters", however my issue has to do with a file that has been loaded, not one being created.

Jul 29, 2011 at 10:00 AM

Same problem here:

Spss.SpssException was unhandled by user code
  Message=SPSS function spssGetValueChar returned error code SPSS_BUFFER_SHORT

This only happens when reading records with string values over 255 characters long. When I change the length in the spss file from 300 to 200 the problem no longer occurs.

May 30, 2014 at 6:46 PM
I think the best way is validate if the variable type is a String, and set a new length to 250.

I have this right now, but I have an exception when I want set to 250, the exception is "Cannot perform this operation after the variable has been committed", if you can do it without the exception will be great, meanwhile I while see how can I fix it.

if (variable.SpssType > 250)
                        var s = variable as SpssStringVariable;
                        if (s != null)
                            if (s.Length > 250) s.Length = 250;