Using MS SQL Binary Data Type

I want to use varBinary to store some values but I'm a little confused on choosing the correct size for the data type. I'm not use to dealing with binary.

I think I understand that Binary is stored as bytes...? If, for example, I have a string that is going to be a maximum of 30 characters long, I would use the nVarChar data type with a size of 30. So if I am storing a password that is no more then 30 characters long (from an array), and saving it as varBinary, would I choose 30 as the size for the binary data type?

Also, I'm looking for a very good buffer to read binary data from the database, are there any excellent examples of a buffer I could use when reading the binary data from the database? Should I also use the buffer when saving data to the database?

Thanks in advance.
[830 byte] By [Shup] at [2007-11-19 22:39:48]
# 1 Re: Using MS SQL Binary Data Type
Have you found your answer to this, Shup?

I have a similar need of inserting/selecting binary data from a SQL Server 2000 table.

I'd appreciate any insight you may have come across.

jim
joleary at 2007-11-9 13:43:50 >
# 2 Re: Using MS SQL Binary Data Type
Post your requirements for taht data. I don't know what a problem is. I'm using binary data in SQL2000 with no problem at all. If U want to store passwords in db then I think it should be avoided. If U cannot live without it :rolleyes: U can use ittaking into account difference between UNICODE string length and number of bytes it takes to store it (and if it is a password than is should be hashed). So what your problem really is? What programming language U prefer to use?

Best regards,
Krzemo.
Krzemo at 2007-11-9 13:44:51 >
# 3 Re: Using MS SQL Binary Data Type
Krzemo-

Thank you for your interest in my problem.

I have created a new thread with the details entitled:

"Multiple-step OLE DB ... errors" on ADO PutValue (http://www.dev-archive.com/forum/showthread.php?t=414076)

I welcome any thoughts you may have about my issue, which has me completely blocked.

Regards,

jim
joleary at 2007-11-9 13:45:49 >