error "the Size property has an invalid size of 0"

hopeful

Member
Joined
Jun 25, 2009
Messages
7
Location
New Zealand
Programming Experience
10+
I have noticed this error appearing a lot on the web so I thought I would share my experience.

I am getting it from an SQLCommand and I suspect that it is related to an output parameter. In my case I suspect that it is because the data type for my parameter is not set properly, and the REASON for this is that I am relying on a call to SQLDataReader.GetSchemaTable which is returning the WRONG data type for an identity column. The column is a long integer in the database, but according to the schema table returned by ADO it is a byte (tinyint). I suspect this is the ultimate reason for the problem.

I will update this if I find out more, otherwise I hope the above may help others.
 

hopeful

Member
Joined
Jun 25, 2009
Messages
7
Location
New Zealand
Programming Experience
10+
Problem solved!

It turns out the actual problem was that the identity column was a tinyint in SQL Server, but MS Access was showing it as a long. To cut a long story short this caused the SQLCommand output parameter to have a DBType of String rather than Byte, and this then caused the "the Size property has an invalid size of 0".

The lesson I have learned from this is not to trust MS Access linked table data types (which I should have already known!), and that if I get the "size of 0" error again I will look closely at the SQLCommand parameter data type and the type of the value being returned.
 

cjard

Well-known member
Joined
Apr 25, 2006
Messages
7,052
Programming Experience
10+
String would probably have worked, as the driver for the database can probably convert a byte to a string without an error, but specifying the size of an output parameter as 0 would likely be an error (and its only applicable to string as far as I know)
 
Top Bottom