a problem with oledb template 
Author Message
 a problem with oledb template

I make a provider project with oledb template

but it does not surport  IRowSerChange

so I can not use Insert() in my consumer project

I want use Insert Update Delete,Who can help me?



Sat, 26 Feb 2005 14:19:07 GMT  
 a problem with oledb template
  CDBPropSet psAll(DBPROPSET_ROWSET);
  psAll.AddProperty(DBPROP_IRowsetChange, true);
  psAll.AddProperty(DBPROP_UPDATABILITY, DBPROPVAL_UP_INSERT |
   DBPROPVAL_UP_DELETE | DBPROPVAL_UP_CHANGE);
  ...
  hr = cmd.Open(session, tszQuery, &psAll);

This propset supports all database operations - you may want
to restrict yours.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

Quote:

> I make a provider project with oledb template

> but it does not surport  IRowSerChange

> so I can not use Insert() in my consumer project

> I want use Insert Update Delete,Who can help me?



Sun, 27 Feb 2005 01:51:52 GMT  
 a problem with oledb template
class CGroup : public CTable<CAccessor<CGroupAccessor> >
{
public:
 HRESULT Open()
 {
  HRESULT  hr;

  hr = OpenDataSource();
  if (FAILED(hr))
   return hr;

  return OpenRowset();
 }
 HRESULT OpenDataSource()
 {
  HRESULT  hr;
  CDataSource db;
  CDBPropSet dbinit(DBPROPSET_DBINIT);

  dbinit.AddProperty(DBPROP_AUTH_PASSWORD, OLESTR(""));
  dbinit.AddProperty(DBPROP_AUTH_USERID, OLESTR("lj"));
  dbinit.AddProperty(DBPROP_INIT_DATASOURCE, OLESTR(""));
  dbinit.AddProperty(DBPROP_INIT_LCID, (long)0);
  dbinit.AddProperty(DBPROP_INIT_LOCATION, OLESTR
("c:\\user\\serverfile.txt"));
  dbinit.AddProperty(DBPROP_INIT_MODE, (long)0);
  dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)2);
  dbinit.AddProperty(DBPROP_INIT_PROVIDERSTRING, OLESTR
(""));
  dbinit.AddProperty(DBPROP_INIT_TIMEOUT, (long)0);
  dbinit.AddProperty(DBPROP_IRowsetChange, true);//I added
  dbinit.AddProperty(DBPROP_UPDATABILITY,
DBPROPVAL_UP_INSERT|DBPROPVAL_UP_DELETE|DBPROPVAL_UP_CHANGE
);

  hr = db.Open(_T("DBProv.Prov.1"), &dbinit);
  if (FAILED(hr))
   return hr;

  return m_session.Open(db);
 }
 HRESULT OpenRowset()
 {
  // The provider is read only so the property change code
has
  // not been generated.
  return CTable<CAccessor<CGroupAccessor> >::Open
(m_session, _T("c:\\user\\group.txt"));
 }
 CSession m_session;

Quote:
};

/////////////
void CHiDlg::OnAdd()
{
 // TODO: Add your control notification handler code here
 TCHAR tchName[22],tchDesp[52];
 UpdateData(1);
 m_group.m_GroupId=m_nId;
 strcpy(tchName,m_strName);
 strcpy(tchDesp,m_strDesp);
 strcpy(m_group.m_GroupName,tchName);
 strcpy(m_group.m_GroupDesp,tchDesp);

 m_group.Insert();//I Step into it

Quote:
}

/////////////////////ATL::CRowSet::Insert
 HRESULT Insert(int nAccessor = 0, bool bGetHRow = false)
 {
  ATLASSERT(m_pAccessor != NULL);
  HRESULT hr;
  if (m_spRowsetChange != NULL)
  {
   HROW* pHRow;
   if (bGetHRow)
   {
    ReleaseRows();
    pHRow = &m_hRow;
   }
   else
    pHRow = NULL;

   hr = m_spRowsetChange->InsertRow(NULL, m_pAccessor-

Quote:
>GetHAccessor(nAccessor),

     m_pAccessor->GetBuffer(), pHRow);

  }
  else
   hr = E_NOINTERFACE;

  return hr;//hr=E_NOINTERFACE
 }

//how can i resolve this problem?



Sun, 27 Feb 2005 14:44:11 GMT  
 a problem with oledb template
So did you read my post at all???

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

Quote:

> class CGroup : public CTable<CAccessor<CGroupAccessor> >
> {
> public:
>  HRESULT Open()
>  {
>   HRESULT  hr;

>   hr = OpenDataSource();
>   if (FAILED(hr))
>    return hr;

>   return OpenRowset();
>  }
>  HRESULT OpenDataSource()
>  {
>   HRESULT  hr;
>   CDataSource db;
>   CDBPropSet dbinit(DBPROPSET_DBINIT);

>   dbinit.AddProperty(DBPROP_AUTH_PASSWORD, OLESTR(""));
>   dbinit.AddProperty(DBPROP_AUTH_USERID, OLESTR("lj"));
>   dbinit.AddProperty(DBPROP_INIT_DATASOURCE, OLESTR(""));
>   dbinit.AddProperty(DBPROP_INIT_LCID, (long)0);
>   dbinit.AddProperty(DBPROP_INIT_LOCATION, OLESTR
> ("c:\\user\\serverfile.txt"));
>   dbinit.AddProperty(DBPROP_INIT_MODE, (long)0);
>   dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)2);
>   dbinit.AddProperty(DBPROP_INIT_PROVIDERSTRING, OLESTR
> (""));
>   dbinit.AddProperty(DBPROP_INIT_TIMEOUT, (long)0);
>   dbinit.AddProperty(DBPROP_IRowsetChange, true);//I added
>   dbinit.AddProperty(DBPROP_UPDATABILITY,
> DBPROPVAL_UP_INSERT|DBPROPVAL_UP_DELETE|DBPROPVAL_UP_CHANGE
> );

>   hr = db.Open(_T("DBProv.Prov.1"), &dbinit);
>   if (FAILED(hr))
>    return hr;

>   return m_session.Open(db);
>  }
>  HRESULT OpenRowset()
>  {
>   // The provider is read only so the property change code
> has
>   // not been generated.
>   return CTable<CAccessor<CGroupAccessor> >::Open
> (m_session, _T("c:\\user\\group.txt"));
>  }
>  CSession m_session;
> };

> /////////////
> void CHiDlg::OnAdd()
> {
>  // TODO: Add your control notification handler code here
>  TCHAR tchName[22],tchDesp[52];
>  UpdateData(1);
>  m_group.m_GroupId=m_nId;
>  strcpy(tchName,m_strName);
>  strcpy(tchDesp,m_strDesp);
>  strcpy(m_group.m_GroupName,tchName);
>  strcpy(m_group.m_GroupDesp,tchDesp);

>  m_group.Insert();//I Step into it
> }

> /////////////////////ATL::CRowSet::Insert
>  HRESULT Insert(int nAccessor = 0, bool bGetHRow = false)
>  {
>   ATLASSERT(m_pAccessor != NULL);
>   HRESULT hr;
>   if (m_spRowsetChange != NULL)
>   {
>    HROW* pHRow;
>    if (bGetHRow)
>    {
>     ReleaseRows();
>     pHRow = &m_hRow;
>    }
>    else
>     pHRow = NULL;

>    hr = m_spRowsetChange->InsertRow(NULL, m_pAccessor-
> >GetHAccessor(nAccessor),
>      m_pAccessor->GetBuffer(), pHRow);

>   }
>   else
>    hr = E_NOINTERFACE;

>   return hr;//hr=E_NOINTERFACE
>  }

> file://how can i resolve this problem?



Mon, 28 Feb 2005 01:44:46 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. a problem with OleDB template

2. OLEDB interfaces vs OLEDB templates

3. ADO vs OLEDB COM vs OLEDB ATL templates

4. ATL - OLEDB consumer template macro problem

5. VC++ OLEDB Templates: call for features/improvements

6. OLEDB Consumer Templates

7. use oledb template in EVC

8. oledb templates

9. Extended error with OLEDB consumer template

10. Help OLEDB templates. Names for tables

11. bug in ATL OLEDB Templates

12. How to insert BLOB data into MSSQL with OLEDB templates library

 

 
Powered by phpBB® Forum Software