473,396 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Create Instance Failed!

Hi, all
Could any boday tell me why I failed to create instance here in the
following code ?

Codes sample
--------------------------------------------------------------------
void CInsertDataTestDlg::OnBnClickedButton1()
{
_ConnectionPtr pMyConnect=NULL;
HRESULT hr=pMyConnect.CreateInstance(__uuidof(Connection)) ;
if(FAILED(hr))return ;
AfxMessageBox(_T("Successfull connected!"), MB_OK)
}
--------------------------------------------------------------------

Thanks in advance!

Joseph
Jul 20 '06 #1
3 5782
"Joseph Lu" <jo******@yahoo.comwrote in message
news:en**************@TK2MSFTNGP04.phx.gbl...
Could any boday tell me why I failed to create instance here in the
following code ?
...
--------------------------------------------------------------------
void CInsertDataTestDlg::OnBnClickedButton1()
{
_ConnectionPtr pMyConnect=NULL;
HRESULT hr=pMyConnect.CreateInstance(__uuidof(Connection)) ;
if(FAILED(hr))return ;
AfxMessageBox(_T("Successfull connected!"), MB_OK)
}
--------------------------------------------------------------------
Um, what is the value of hr?

Regards,
Will
Jul 20 '06 #2
the value of hr is : 0x800401f0 , my code is very simple, I used VC to
create a dialog based application and the create a new button on the dialog,
then I added a button click event to this app ,and I have listed the code as
my previous mail detailed .
"William DePalo [MVP VC++]" <wi***********@mvps.orgдÈëÏûÏ¢
news:%2****************@TK2MSFTNGP05.phx.gbl...
"Joseph Lu" <jo******@yahoo.comwrote in message
news:en**************@TK2MSFTNGP04.phx.gbl...
> Could any boday tell me why I failed to create instance here in the
following code ?
...
--------------------------------------------------------------------
void CInsertDataTestDlg::OnBnClickedButton1()
{
_ConnectionPtr pMyConnect=NULL;
HRESULT hr=pMyConnect.CreateInstance(__uuidof(Connection)) ;
if(FAILED(hr))return ;
AfxMessageBox(_T("Successfull connected!"), MB_OK)
}
--------------------------------------------------------------------

Um, what is the value of hr?

Regards,
Will

Jul 20 '06 #3
Well , I got it, I find I need to call AfxOleInit() before create instance!

"Joseph Lu" <jo******@yahoo.comдÈëÏûÏ¢
news:ux**************@TK2MSFTNGP03.phx.gbl...
the value of hr is : 0x800401f0 , my code is very simple, I used VC to
create a dialog based application and the create a new button on the
dialog, then I added a button click event to this app ,and I have listed
the code as my previous mail detailed .
"William DePalo [MVP VC++]" <wi***********@mvps.orgдÈëÏûÏ¢
news:%2****************@TK2MSFTNGP05.phx.gbl...
>"Joseph Lu" <jo******@yahoo.comwrote in message
news:en**************@TK2MSFTNGP04.phx.gbl...
>> Could any boday tell me why I failed to create instance here in the
following code ?
...
--------------------------------------------------------------------
void CInsertDataTestDlg::OnBnClickedButton1()
{
_ConnectionPtr pMyConnect=NULL;
HRESULT hr=pMyConnect.CreateInstance(__uuidof(Connection)) ;
if(FAILED(hr))return ;
AfxMessageBox(_T("Successfull connected!"), MB_OK)
}
--------------------------------------------------------------------

Um, what is the value of hr?

Regards,
Will


Jul 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Shashikant Khandelwak | last post by:
Hi ! I am trying to install oracle 9i Standard edition on a windows 2000 SP4 machine. I get through the entire installation up to running the Database Configuration Assistant. While it tries to...
15
by: Viviana Vc | last post by:
How can I programatically do the equivalent of the following: cacls "C:\Program Files\test" /T /G Everyone:f ? Thanks, Viv
8
by: Steve Neill | last post by:
Can anyone suggest how to create an arbitrary object at runtime WITHOUT using the deprecated eval() function. The eval() method works ok (see below), but is not ideal. function Client() { }...
2
by: R. Clausen | last post by:
I am wanting to create a database in UDB (WIN) v8 FP4 using a backup from UDB (WIN) v7.2 FP4. When the restore is complete, I get a DB2 Message 'The command completed successfully.', however, when...
9
by: jab | last post by:
Je veux lier (join) une table qui se trouve dans une database avec une qui se trouve dans une autre database. Les 2 databases sont sur le même serveur en l'occurence DB2/NT 7.2.9. J'ai créé un...
20
by: Hemant Shah | last post by:
Folks, I am using DB2 UDB 8.2 on AIX 5.1. How large of a bufferpool can you create? I tried to create a 4GB bufferpool db2 complained that is cannot allocate enogth memory. I have 16GB on this...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
0
by: Terry Reedy | last post by:
Fredrik Lundh wrote: If you do not want the instance created at all, you would have to write a custom .__new__ method, but that is tricky, something I would have to look up how to do, and most...
6
by: Mr. X. | last post by:
Hello. How can I create aspnetdb from scratch ? (I want a script that create all table, views, etc... on that database). Thanks :)
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.