How to specify UNSIGNED Byte in MS Access?

  • Thread starter chris.peressotti
  • Start date
C

chris.peressotti

Hi. I have a MATLAB program that interacts with an MS Access database
via MATLAB's "fastinsert" command.

In one table, I'm inserting RGB pixel values, so it seemed natural
that I'd use the "Byte" field size; however I eventually ran into a
problem: I'm not allowed to insert values higher than 127 into the
Byte columns! This would make sense if I had specified a signed-byte,
but is there even such a thing? The Access documentation states that
"Byte" can handle values from 0-255, and I haven't found anything else
to explain this.

A simple way around this is to just specify the field size as, say
Integer, but that also seems like a waste of space.

Does anyone know what I'm doing wrong?

- Chris
 
A

Allen Browne

As the documentation says, Access *only* has the unsigned byte (at least in
the interface.)

If you are getting a different result, then you don't have the data in an
Access table. Perhaps the table is linked from another database.
 
C

chris.peressotti

As the documentation says, Access *only* has the unsigned byte (at least in
the interface.)

If you are getting a different result, then you don't have the data in an
Access table. Perhaps the table is linked from another database.

It's definitely Access (I created it) but I realize now that the
problem definitely lies with MATLAB -- working in Access' spreadsheet
mode, I was able to manually set the value in a Byte column to be
higher than 127. So I've started a new thread over there.

Thanks!

- Chris
 
A

Albert D. Kallal

Hum, I am able to insert values...as long as they fall in the range

0-255

Are you perhaps using a "expression"?

Just put a cbyte(your expression) to "cast" the values to byte...it should
work...
 
C

chris.peressotti

Hum, I am able to insert values...as long as they fall in the range
0-255
Are you perhaps using a "expression"?
Just put a cbyte(your expression) to "cast" the values to byte...it should
work...

I decided that the "problem" must lie with MATLAB, so I contacted
their support department and here's the answer:
"TINYINT's can only go from -128 to 127. We are adhering to the Java
types and will probably not want to change it in FASTINSERT. You can
use INSERT instead, as you just did, since it doesn't use the Java set
methods. Alternatively you can change the data type of the field in MS
Access to Integer.

A quick fix would also be to change line 149 of fastinsert from
setByte to setInt; however I do not know if this will affect any
future operations. Please let me know the results of trying out the
above suggestions."

This may not be of much interest to the majority of MS Access users,
but I thought it'd be useful to post in case anyone else happens to be
trying (and failing) the same thing.

Thanks for your help/suggestions,

- Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top