You're kidding, right? I've got several places where there are enum casts
since combining two enum values results in an int. OTOH, having the variable
declared as the enum type makes it simpler in the debugger. So, you trade
one inconvenience for another...
Ciao,
Dee
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf
Of Mark J. McGinty
Sent: Wednesday, October 15, 2003 10:40 PM
To: Yosvel Reyes; MSVC Mailing List; Windev Mailing List
Subject: RE: [windev] ADO Parameter object
> (DataTypeEnum)(adArray | adChar)
I don't think your data type for the parameter is valid, try
adLongVarBinary... heh, not sure I've ever seen anyone typecast a value to
an enum type, so you get an 'o' for original there. :-)
-Mark
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf
> Of Yosvel Reyes
> Sent: Tuesday, October 14, 2003 1:29 PM
> To: MSVC Mailing List; Windev Mailing List
> Subject: [windev] ADO Parameter object
>
>
> Hi All:
>
> Dev env. VC++ .NET SQL Server 2000 Win2k Advanced Server
> I'm trying to write some BLOB data to a field on my database. I want
> perform this using a stored procedure whos expect like 3rd parameter a
> BLOB. also I 'm using the Parameter's Object AppendChunk method and when
> I try to call it
> I got the following error:
>
> Operation not allowed on this context!!!
>
> Here list my code:
>
> BOOL CDBManager::InsertPublication(long lPubID, const char* pszPubTitle,
> const char* pszPubContent)
> {
>
> _CommandPtr theCommand;
> BOOL bRet;
> HRESULT hr;
> VARIANT vChunk;
>
> try{
>
> if(!m_bConnected)return FALSE;
>
> bRet = FALSE;
> hr = theCommand.CreateInstance(__uuidof(Command));
> if(SUCCEEDED(hr)){
>
>
>
> theCommand->put_ActiveConnection(_variant_t(m_Connection, false));
>
> theCommand->put_CommandText(_bstr_t(SPN_INSERT_PUBLICATION));
> theCommand->put_CommandType(adCmdStoredProc);
>
> //setting up parameters
>
> //Append the first parameter (theme ID)
> hr =
> theCommand->GetParameters()->Append(theCommand->CreateParameter(_b
> str_t("Theme"),
>
>
> adInteger,
>
>
> adParamInput,
>
>
> sizeof(long),
>
>
> _variant_t(lPubID)));
>
> if(SUCCEEDED(hr)){
>
> //Append the 2nd parameter (the
> publication title)
> hr =
> theCommand->GetParameters()->Append(theCommand->CreateParameter(_b
> str_t("Title"),
>
>
> adBSTR,
>
>
> adParamInput,
>
>
> strlen(pszPubTitle),
>
>
> _variant_t(pszPubTitle)));
>
> if(SUCCEEDED(hr)){
>
>
> //Append the 3rd parameter
> (the contents) I mean the BLOB...
> _ParameterPtr theBlob;
> long length;
> SAFEARRAY* psa;
> SAFEARRAYBOUND rgsabounds[1];
> char
> szString[1024];
>
> //Create the 3rd parametetr
> length = strlen(pszPubContent);
> theBlob =
> theCommand->CreateParameter( _bstr_t("Article"),
>
>
> (DataTypeEnum)(adArray | adChar),
>
> adParamInput,
>
> length);
>
>
> //create a safe array of
> length bytes to store data
> rgsabounds[0].lLbound = 0;
> rgsabounds[0].cElements = length;
>
> psa =
> SafeArrayCreate(VT_UI1, 1, &rgsabounds[0]);
>
> if(psa != NULL){
>
> //copies byte to
> byte the contents for the array
> for(long index = 0;
> index < length; index++)
>
> SafeArrayPutElement(psa, &index, (void*)&pszPubContent[index]);
>
> vChunk.vt =
> VT_ARRAY | VT_UI1;
> vChunk.parray = psa;
>
> //Appends the chunk
> inside the parameter
>
> theBlob->AppendChunk(vChunk);
>
> //Add parameter to
> parameters collectio for current command
> hr =
> theCommand->GetParameters()->Append(theBlob);
>
> if(SUCCEEDED(hr)){
> _variant_t vError;
>
> vError.vt =
> VT_ERROR;
>
> vError.scode = DISP_E_PARAMNOTFOUND;
>
> //Executes
> the command
>
> theCommand->Execute(&vError, &vError, adExecuteNoRecords);
> bRet = TRUE;
> }
>
> //Cleanup array and
> variants...
> SafeArrayDestroy(psa);
>
> }
>
> }
>
>
> }
>
> //Cleanup the connection
> theCommand->putref_ActiveConnection(NULL);
> theCommand = NULL;
> }
> }
> catch(_com_error& e){
> ManageCOMError(e);
> }
> catch(...){
> ManageError("Unknown Error");
> }
>
> return bRet;
> }
>
>
> Any suggestion about the problem will be very helpful
> Thanks in advance
>
>
>
> ==========================================
> Lic. Yosvel Reyes Fonfria
> [EMAIL PROTECTED]
> tel: (053)42 205428
>
> Who try and try again, triumph!!!
> ==========================================
>
> --
> http://www.fastmail.fm - Sent 0.000002 seconds ago
> --
> Windev mailing list at [EMAIL PROTECTED]
>
> Lost your password? Need to unsubscribe or change your delivery
> options?
> Go to http://www.lesher.ws/mailman/listinfo/windev
> --
> Search the Windev Archives - www.windev.org
--
Windev mailing list at [EMAIL PROTECTED]
Lost your password? Need to unsubscribe or change your delivery options?
Go to http://www.lesher.ws/mailman/listinfo/windev
--
Search the Windev Archives - www.windev.org
