472,955 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,955 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 5758
"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 :)
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
1
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.