Retrieving a byte array stored in a INT field in the database

how do I retrieve the byte array stored in an integer column in my database?

Do I first case it as int, then as byte[] ?

byte[] permissions = (byte) Convert.ToInt(dr["myField"]);



Well, the data is stored as an integer. How do you want to convert that into a byte array. Given an input of, say, 12345, what should the output be?

Why are you trying to store a byte array in an integer column in the first place?

EDIT: Now that we know that it's basically flags you're after, I wouldn't convert it to a byte array, I'd use an enum:

public enum Permissions
    Read = 1,
    Write = 2,
    Execute = 4,
    Guillotine = 8,
    Lynch = 16
    // etc

Then you can just cast:

Permissions permissions = (Permissions) (int) dr["Field"]

Need Your Help

Python ISRIStemmer for Arabic text

python utf-8 arabic stemming

I am running the following code on IDLE(Python) and I want to enter Arabic string and get the stemming for it but actually it doesn't work

Virtual Private Server Hosting vs. Colo + Own Server(s) for Early-Stage Web-App

hosting vps web-applications colocation

I'm working on a web-application and need to figure out the best way to host it. I'm looking to minimize "Total Cost of Ownership," but it's more important to keep hosting costs low than labor cost...