Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Insert an image into SQL with stored procedure

7 views
Skip to first unread message

eusebiu

unread,
Oct 18, 2007, 10:05:27 AM10/18/07
to
Hello.
I have a SQL table with one column that has the type = image.
I have a Stored procedure that inserts an image into that table.
CREATE PROCEDURE [dbo].[Test]
@test image
AS
BEGIN
insert into Table_1(test)values(@test)
END

I am using ADO in C++ for creating a connection,command, and
parameters.
VARIANT par;
par.vt = VT_UI1;
par.pbVal = (BYTE*)pBuffer;

pCommand->Parameters->Append(pCommand-
>CreateParameter("test",DataTypeEnum::adArray,
ParameterDirectionEnum::adParamInput,strlen(pBuffer),par));
pRecordset = pCommand-
>Execute(NULL,NULL,CommandTypeEnum::adCmdStoredProc);
where
_CommandPtr pCommand;
pCommand->CommandText = (_bstr_t)procedureName;
pCommand->CommandType = CommandTypeEnum::adCmdStoredProc;

When I append the created parameter, in comutil.h, at these lines :
namespace _com_util {
inline void CheckError(HRESULT hr) throw(...)
{
if (FAILED(hr)) {
_com_issue_error(hr);
}
}
}
I get an exception : m_hresult 0x80020008 Bad variable type.

If I try to insert a string or an number, it works. But with BYTE* it
dosen't.

Can someone help me?
Thanks

0 new messages