VB Arrays and User-defined Datatypes

  • kherc

    SSC Veteran

    Points: 204

    Is there any way to store in one field a VB Array or a variable of a User-Defined datatype?

  • Andy Warren

    SSC Guru

    Points: 119684

    Only if you control the data yourself. It's just like putting XML or a word doc in a blob - it's structured, but SQL doesn't know that. You could just write your array out to a string with some type of delimiter for storage, then parse back into an array when you retrieve it. Take a look at Split & Join functions in VB for an easy way to do this.

    It's a rare case when this is a good idea.

    Andy

    Andy

  • kherc

    SSC Veteran

    Points: 204

    There is a high size cost with this method.

    I found that I can directly store an Array of Bytes in a Varbinary field. Then I can get the contents of the field in a variant and read the array fields as usual. It's more complicate in code but less size expensive

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply