• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 843
  • Last Modified:

SetParameterInfo issues

Here is my code:

void OleDbConfigurationTable::Insert(const ::boost::shared_ptr<CSession> oledbSessionPtr,  const ByteArray& configuration)
{
      CCommand<CAccessor<configuration::InsertAccessor>, CNoRowset> oledbCommand;
      LONG rowsAffected = 0;
      HRESULT hr = S_OK;

      try
      {
            //setting blob...
            OleDbBlobStream cfgStream;
            oledbCommand.colConfiguration = SetBlobColumn(
                              configuration,
                              cfgStream,
                              oledbCommand.lenConfiguration,
                              oledbCommand.stsConfiguration );

        ULONG prgParamOrdinals[1]={ULONG1};
        DBPARAMBINDINFO prgParamBindInfo[1];

        prgParamBindInfo[0].pwszDataSourceType = L"BLOB";
        prgParamBindInfo[0].dwFlags = DBPARAMFLAGS_ISINPUT;
        prgParamBindInfo[0].pwszName = NULL;
        prgParamBindInfo[0].ulParamSize = oledbCommand.lenConfiguration;

       hr =  oledbCommand.SetParameterInfo((ULONG)1 , prgParamOrdinals , prgParamBindInfo);
      hr = oledbCommand.Open(*oledbSessionPtr, (LPCWSTR)NULL, NULL, &rowsAffected);

It bombs on the SetParameterInfo, failing this assertion:

      _NoAddRefReleaseOnCComPtr<T>* operator->() const throw()
      {
            ATLASSERT(p!=NULL);
            return (_NoAddRefReleaseOnCComPtr<T>*)p;
      }
0
h2hjastermereel
Asked:
h2hjastermereel
  • 5
  • 4
1 Solution
 
itsmeandnobodyelseCommented:
>>>> It bombs on the SetParameterInfo, failing this assertion:
You may check the callstack what calls are above the operator->() call.

>>>> prgParamBindInfo[0].pwszName = NULL;
Do you know for sure that the name can be NULL?

0
 
itsmeandnobodyelseCommented:
>>>> operator->()
operator-> is overloaded for smart pointers and iterators.

>>>> ATLASSERT(p!=NULL);

means that the smart pointer or iterator has no *real* pointer (node) where it could operate on.
0
 
h2hjastermereelAuthor Commented:
itsmeandnobodyelse,

Yeah that much I understood from the message, however based on the above code what am I missing?

-J
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
itsmeandnobodyelseCommented:
>>>> however based on the above code what am I missing?
Did you examine the callstack? If you go down the calls you maybe see where the NULL pointer (which was called 'p' in the operator->)  initially was set. It should be the constructor of  some template class.
 
>>>> prgParamBindInfo[0].pwszName = NULL;
Why has the BLOB column no name? I could imagine that because of that some query fails and returns a NULL pointer because of that.
0
 
h2hjastermereelAuthor Commented:
The name can be null without issue b/c the ordinality of the column is set. Most examples leave this blank. I added it anyway - same results.


stack:

>      DB2.dll!ATL::CComPtrBase<ICommand>::operator->()  Line 154 + 0x32 bytes      C++
       DB2.dll!ATL::CCommandBase::SetParameterInfo(unsigned long ulParams=1, const unsigned long * pOrdinals=0x0013ceb8, const tagDBPARAMBINDINFO * pParamInfo=0x0013ce9c)  Line 6660 + 0x11 bytes      C++
0
 
itsmeandnobodyelseCommented:
>>>> name can be null without issue b/c the ordinality of the column is set.
ok. It was only a guess at it was the only obvious null pointer.

>>>> DB2.dll!ATL::CCommandBase::SetParameterInfo
did you double-click at the calling function? It should use the -> operator. You might go up some statements trying to find out how the variable where the -> operation was made on was created by assigning a pointer value. For any reason the right side of that assignment is NULL - or if a function call - returns a NULL pointer.
0
 
itsmeandnobodyelseCommented:

>>>> DBPARAMBINDINFO prgParamBindInfo[1];
You should initialize all members of the struct by

ULONG prgParamOrdinal = ULONG1;
DBPARAMBINDINFO prgParamBindInfo[1] = { { 0 }, };

or make it easier

    ULONG prgParamOrdinal = ULONG1;
    DBPARAMBINDINFO prgParamBindInfo = { 0 };

and pass it like

    hr =  oledbCommand.SetParameterInfo(1 , &prgParamOrdinal , &prgParamBindInfo);
0
 
h2hjastermereelAuthor Commented:
Ok traced it a bit and it is failing here:

CComPtr<ICommandWithParameters> spCommandParameters;
HRESULT hr = m_spCommand->QueryInterface(&spCommandParameters);

which is in ATLDBCLI

the m_spCommand is a null pointer.  This is a member of my command obj, so I assume where I have:

CCommand<CAccessor<configuration::InsertAccessor>, CNoRowset> oledbCommand;

this pointer is not being set.  I can't find anything out there showing how to create a valid pointer for this obj.

-J
0
 
h2hjastermereelAuthor Commented:
ok so the problem was I needed to do a Create on the Command before calling SetParamterInfo
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now