Click here to Skip to main content
15,939,960 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to Read/Write to a file a structure wich contains Cstring ? Pin
Cedric Moonen13-Dec-10 3:25
Cedric Moonen13-Dec-10 3:25 
AnswerRe: how to Read/Write to a file a structure wich contains Cstring ? Pin
Richard MacCutchan13-Dec-10 7:19
mveRichard MacCutchan13-Dec-10 7:19 
QuestionSHFileOperation in win XP? Pin
zon_cpp12-Dec-10 19:23
zon_cpp12-Dec-10 19:23 
AnswerRe: SHFileOperation in win XP? Pin
CPallini12-Dec-10 20:59
mveCPallini12-Dec-10 20:59 
GeneralRe: SHFileOperation in win XP? Pin
zon_cpp12-Dec-10 22:24
zon_cpp12-Dec-10 22:24 
Questionsave image with annotation Pin
raju_shiva12-Dec-10 18:53
raju_shiva12-Dec-10 18:53 
AnswerRe: save image with annotation Pin
Hadi Dayvary13-Dec-10 7:02
professionalHadi Dayvary13-Dec-10 7:02 
QuestionException Pin
MsmVc12-Dec-10 18:38
MsmVc12-Dec-10 18:38 
Hi All


I try to create database and table in Access database through this way.
_CatalogPtr m_pCatalog  = NULL;
CString con="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test.mdb;Jet OLEDB:Engine Type=5";
 HRESULT hr = S_OK;
		   try
 	{
			
		
       TESTHR(hr = m_pCatalog.CreateInstance(__uuidof (Catalog)));
	
	m_pCatalog->Create((_bstr_t)con);
}
 catch(_com_error pCE)
    {
}


.
.//create table
.
.
m_pCatalog->Release();
 CoUninitialize();   

Database name(test.mdb) read from list(list have more than one database name).I use here m_pCatalog->Release();
Now when i select different database name that time this line TESTHR(hr = m_pCatalog.CreateInstance(__uuidof (Catalog)));
through exception.
Exception show
HRESULT CreateInstance(const CLSID& rclsid, IUnknown* pOuter = NULL, DWORD dwClsContext = CLSCTX_ALL) throw()
   {
       HRESULT hr;

          point out this line 
       _Release();//this line

       if (dwClsContext & (CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER)) {
           IUnknown* pIUnknown;
           hr = CoCreateInstance(rclsid, pOuter, dwClsContext, __uuidof(IUnknown), reinterpret_cast<void**>(&pIUnknown));

           if (SUCCEEDED(hr)) {
               hr = OleRun(pIUnknown);

               if (SUCCEEDED(hr)) {
                   hr = pIUnknown->QueryInterface(GetIID(), reinterpret_cast<void**>(&m_pInterface));
               }

               pIUnknown->Release();
           }
       }
       else {
           hr = CoCreateInstance(rclsid, pOuter, dwClsContext, GetIID(), reinterpret_cast<void**>(&m_pInterface));
       }

       if (FAILED(hr)) {
           // just in case refcount = 0 and dtor gets called
           m_pInterface = NULL;
       }

       return hr;
   }


I use m_pCatalog->Release() because once i create database and table then i try to free particular database.
Please help me
QuestionRe: Exception Pin
CPallini12-Dec-10 21:08
mveCPallini12-Dec-10 21:08 
AnswerRe: Exception Pin
MsmVc12-Dec-10 22:22
MsmVc12-Dec-10 22:22 
QuestionRe: Exception Pin
CPallini12-Dec-10 22:30
mveCPallini12-Dec-10 22:30 
AnswerRe: Exception Pin
MsmVc12-Dec-10 22:59
MsmVc12-Dec-10 22:59 
QuestionDear buddy, I am mad, can you help me and don't drop me as sacrifice Pin
nenfa12-Dec-10 16:58
nenfa12-Dec-10 16:58 
AnswerRe: Dear buddy, I am mad, can you help me and don't drop me as sacrifice Pin
nenfa14-Dec-10 15:09
nenfa14-Dec-10 15:09 
QuestionCan not delete multiple files with ReadDirectoryChangesW Pin
ShadowUz12-Dec-10 13:30
ShadowUz12-Dec-10 13:30 
AnswerRe: Can not delete multiple files with ReadDirectoryChangesW Pin
Luc Pattyn12-Dec-10 14:12
sitebuilderLuc Pattyn12-Dec-10 14:12 
QuestionRe: Can not delete multiple files with ReadDirectoryChangesW Pin
David Crow13-Dec-10 3:16
David Crow13-Dec-10 3:16 
QuestionCreate Bitmap from mousemovement in picturebox MFC Pin
josipahutar12-Dec-10 9:48
josipahutar12-Dec-10 9:48 
AnswerRe: Create Bitmap from mousemovement in picturebox MFC Pin
Alain Rist12-Dec-10 10:00
Alain Rist12-Dec-10 10:00 
GeneralRe: Create Bitmap from mousemovement in picturebox MFC Pin
josipahutar13-Dec-10 7:21
josipahutar13-Dec-10 7:21 
GeneralRe: Create Bitmap from mousemovement in picturebox MFC Pin
David Crow13-Dec-10 8:01
David Crow13-Dec-10 8:01 
GeneralRe: Create Bitmap from mousemovement in picturebox MFC Pin
Alain Rist13-Dec-10 9:20
Alain Rist13-Dec-10 9:20 
Question[Solved] Speech sample not running.... [modified] Pin
AmbiguousName12-Dec-10 8:01
AmbiguousName12-Dec-10 8:01 
AnswerRe: Speech sample not running.... Pin
Richard MacCutchan12-Dec-10 9:37
mveRichard MacCutchan12-Dec-10 9:37 
AnswerRe: Speech sample not running.... Pin
Emilio Garavaglia12-Dec-10 9:42
Emilio Garavaglia12-Dec-10 9:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.