Re: Beginner's Question on binary arrays and storage
From: Erland Sommarskog (sommar_at_algonet.se)
Date: 05/05/04
- Next message: Aneesh Aravind: "Re: return every day in a date range"
- Previous message: Hugo Kornelis: "Re: Can someone please explain this ?"
- In reply to: B. Chernick: "Beginner's Question on binary arrays and storage"
- Next in thread: B. Chernick: "Re: Beginner's Question on binary arrays and storage"
- Reply: B. Chernick: "Re: Beginner's Question on binary arrays and storage"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Aneesh Aravind: "Re: return every day in a date range"
- Previous message: Hugo Kornelis: "Re: Can someone please explain this ?"
- In reply to: B. Chernick: "Beginner's Question on binary arrays and storage"
- Next in thread: B. Chernick: "Re: Beginner's Question on binary arrays and storage"
- Reply: B. Chernick: "Re: Beginner's Question on binary arrays and storage"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|