Re: Beginner's Question on binary arrays and storage

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Erland Sommarskog (sommar_at_algonet.se)
Date: 05/05/04


Date: Wed, 5 May 2004 22:32:18 +0000 (UTC)

B. Chernick (anonymous@discussions.microsoft.com) writes:
> I am running Visual Studio 2003 and MSDE 2000. I am fairly new to SQL
> Server.
>
> I would like to store a bit array of 96 bits in a SQL record.
>
> In my VB code I have defined the array as 'Dim x As New BitArray(96)'.
> In my database table I have defined a field as Binary with a length of
> 12 bytes (presumably 8 bits per byte.)
>
> Are my assumptions correct so far?

Yes and no. You could store a number of bits in a binary, but question
is whether this is really a good idea. The the bit mask is just some
opaque set of bits that does not mean anything to the database, it would
be alright. But judging from your column names this is not the case.
If you are performing any sort of logic on the bit mask in the data
base, you are probably on the wrong path.

A fundamental rule when it comes to database design is: no repeating
groups. That is, a row in a table should have any array data. You
should have columns that holds a comma-separated lists with the sales
values for January, February etc. Neither should you have columns like
Sales_jan, Sales_feb etc.

And your bitmask appears to me to be a repeating group. The alternative
would be to have a table with employee id, start of slot, length of slot
and busy/free marker. Of course that will take up space, but it may
also be a lot more performant, since it is so easy to find data for
a slot.

> My real problem is that I am trying to run a stored procedure to insert
> the record and although the syntax checks out correctly, I always get
> the error 'Object must implement IConvertible'. This happens at the
> point of ExecuteNonQuery. I still have no idea what this means.

That message is a VB .Net message. I'm not any .Net master, but I read
the message as you have passed a datatype which does provide any
conversion to SqlParameter.Value. You should probably ask in a .Net group
about this.

-- 
Erland Sommarskog, SQL Server MVP, sommar@algonet.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp


Relevant Pages

  • Re: need some help with this solution...
    ... the whole file in a similar way as when fetching rows from the database (see ... You can choose to process the rows at the same time you fgetit or store ... uploaded file is a big one, then you will use more RAM if you store it in an ... Once I get the array ...
    (alt.php)
  • vb 2005 express > querry table in access and put contents into array
    ... I have a database that holds employee data. ... the phone login ID's for all of the agents in the table who are still ... i want to store each of those phone logins in an array, ... i just don't know how to make VB execute this statement and store the ...
    (microsoft.public.dotnet.languages.vb)
  • Re: pause processing
    ... I'd like to give the user an opportunity to examine the print_rof that array before continuing. ... When the user submits the form, store the data in the database. ... If the data's not too big, you can store it in the $_SESSION array. ... if variable-pass1 is not set ...
    (comp.lang.php)
  • Re: BinaryFormatter Version mismatch
    ... My application is a business process ... > related data in the database as a blob. ... Make sure you can store a byte array in your database and retrieve ...
    (microsoft.public.dotnet.framework)
  • Re: KirbyBase
    ... creating objects from the database records was much easier. ... Hal, I don't know if you have had a chance to take a look at the beta yet, but I basically tried to implement a uniform way to specify one-to-one links, one-to-many links, and calculated fields in the ... I suppose it would in effect be embedding an array where all the ... My first couple of attempts at adding more complexity to KirbyBase did not honor this concept. ...
    (comp.lang.ruby)