[VC++ 6.0, SQL Server] Cross-posted from Visual C++ Programming

After using Triple-DES encryption, I end up with a BYTE* array of encrypted binary data that I need to store in my SQL Server database table. But I cannot seem to find the right way to get it into the table.

(The code to convert the BYTE* array to BSTR below was provided by the VC++ forum. The structure of the resulting BSTR seems correct when I view it in the debugger. But, if you have any other suggestions for how to get the BYTE* array into the database other than BSTR, I'd gladly entertain them as well.)

In my example below, I have conjured an ordinary BYTE* array similar to what I might get from my encryption routine.

I get the this error when I execute the assignment on the last line of the following code:

"Multiple-step OLE DB operation generated errors. Check each OLE DB value, if available. No work was done."

Code:
CString csState = "MA";
BYTE* bt = new BYTE [256]
	for (int i = 0; i < 256; i++)  //my initialization for testing
	{
		bt[i] = i + 1;
	}
BSTR bstrBuff = SysAllocStringLen((LPOLESTR)bt,256);

pRst->Fields->GetItem("state")->Value = (_bstr_t) csState;
pRst->Fields->GetItem("data")->Value = bstrBuff;
The assignment of 'state' [varchar(2)] is OK. When csState has 3 characters, I get the same error.

A recurring theme in the forum(s) and on the web for this error around this kind of operation is:
the value is not suitable for the field to store.

The database field 'data' is declared as varchar(600). I also tried varbinary(600). I'm not sure what is not suitable about these typedefs.

So, I am at a loss for an explanation.

Once, this data is in the database, I will need to get it out and back into a BYTE* array for decryption. If you have any thoughts about that, they would also be greatly appreciated.

Thanks for any thoughts,

jim