Click here to Skip to main content
15,885,757 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questiondisable auto-complete in dropdown [modified] Pin
elephantstar30-May-06 6:10
elephantstar30-May-06 6:10 
AnswerRe: disable auto-complete in dropdown [modified] Pin
valikac30-May-06 6:45
valikac30-May-06 6:45 
GeneralRe: disable auto-complete in dropdown [modified] Pin
elephantstar30-May-06 7:20
elephantstar30-May-06 7:20 
GeneralRe: disable auto-complete in dropdown [modified] Pin
valikac30-May-06 7:29
valikac30-May-06 7:29 
GeneralRe: disable auto-complete in dropdown [modified] Pin
elephantstar30-May-06 14:24
elephantstar30-May-06 14:24 
GeneralRe: disable auto-complete in dropdown [modified] Pin
valikac30-May-06 15:36
valikac30-May-06 15:36 
QuestionPrevent CListCtrl from hiding scrollbar Pin
stefisko30-May-06 6:08
stefisko30-May-06 6:08 
QuestionHelp Pls - C++ and ADO problem Pin
antonaras30-May-06 5:39
antonaras30-May-06 5:39 
Hi again
I'm trying to connect to an access db using ADO
i use some sample codes to perform a simple SELECT query and display them through a recordset. I've tryed really hard to make it work i've searched everywhere pls help me find the problem.
This is the code i use::

<br />
#include <windows.h><br />
#include <stdio.h><br />
#include <iostream.h><br />
<br />
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" \<br />
no_namespace rename("EOF", "EndOfFile")<br />
<br />
void main(int argc, char* argv[])<br />
{<br />
<br />
HRESULT hr = S_OK;<br />
_ConnectionPtr m_pConn;<br />
    try<br />
	{<br />
		HRESULT hr = m_pConn.CreateInstance(__uuidof(Connection));<br />
		if (FAILED( hr ))<br />
			cout<<"Can't create an intance of ADO.Connection"<<endl;<br />
 <br />
		if (FAILED( m_pConn->Open(_bstr_t("Provider=Microsoft.Jet.OLEDB.4.0;Data Source =ADOTestDB.MDB"),<br />
			_bstr_t( "" ),<br />
			_bstr_t( "" ), <br />
			adModeUnknown )))<br />
			<br />
			cout<<"Can't open datasource"<<endl;<br />
<br />
<br />
		_CommandPtr pCommand;<br />
		pCommand.CreateInstance (__uuidof (Command));<br />
		pCommand->ActiveConnection = m_pConn; <br />
		pCommand->CommandText = "Select Name,Dept From Student";<br />
		_RecordsetPtr pRecordset;<br />
		pRecordset.CreateInstance (__uuidof (Recordset));<br />
		pRecordset->CursorLocation = adUseClient;<br />
		pRecordset->Open ( (IDispatch *) pCommand, vtMissing, adOpenStatic,<br />
		adLockBatchOptimistic, adCmdUnknown);<br />
<br />
		_bstr_t valField1;<br />
		int valField2;<br />
		pRecordset->MoveFirst();<br />
		if (!pRecordset->EndOfFile)<br />
		{<br />
			while(!pRecordset->EndOfFile)<br />
			{<br />
			valField1 = pRecordset->Fields->GetItem("Name")->Value;<br />
			valField2 = pRecordset->Fields->GetItem("Dept")->Value.intVal;<br />
				printf("%d - %s\n",valField2,(LPCSTR)valField1);<br />
				pRecordset->MoveNext();<br />
			}<br />
		}<br />
<br />
		<br />
	}catch( _com_error &ce )<br />
	{<br />
		printf("Error:%s\n",ce.Description);<br />
<br />
	}<br />
	m_pConn->Close();<br />
<br />
}<br />


i get an exeption
"Can't create an intance of ADO.Connection"
and the i asks if i want to debug
Pls help me i'm trying a lot to connect to a db and enything i do seems to be wrong
and the truth is that everytime i post a msg about C++ and ADO no one
replies.
pls i'm desparate
AnswerRe: Help Pls - C++ and ADO problem Pin
Steve S30-May-06 6:10
Steve S30-May-06 6:10 
GeneralRe: Help Pls - C++ and ADO problem Pin
antonaras30-May-06 6:25
antonaras30-May-06 6:25 
GeneralRe: Help Pls - C++ and ADO problem Pin
Steve S30-May-06 6:37
Steve S30-May-06 6:37 
GeneralRe: Help Pls - C++ and ADO problem Pin
antonaras30-May-06 6:50
antonaras30-May-06 6:50 
GeneralRe: Help Pls - C++ and ADO problem Pin
Jörgen Sigvardsson30-May-06 13:32
Jörgen Sigvardsson30-May-06 13:32 
GeneralRe: Help Pls - C++ and ADO problem Pin
Steve S30-May-06 22:24
Steve S30-May-06 22:24 
QuestionBeginner MFC Dialog Problems Pin
aei_totten30-May-06 5:32
aei_totten30-May-06 5:32 
AnswerRe: Beginner MFC Dialog Problems Pin
Zac Howland30-May-06 5:48
Zac Howland30-May-06 5:48 
GeneralRe: Beginner MFC Dialog Problems Pin
aei_totten30-May-06 8:13
aei_totten30-May-06 8:13 
QuestionRe: Beginner MFC Dialog Problems Pin
Hamid_RT30-May-06 8:44
Hamid_RT30-May-06 8:44 
AnswerRe: Beginner MFC Dialog Problems Pin
aei_totten30-May-06 9:14
aei_totten30-May-06 9:14 
GeneralRe: Beginner MFC Dialog Problems Pin
Eric Dahlvang30-May-06 9:14
Eric Dahlvang30-May-06 9:14 
GeneralRe: Beginner MFC Dialog Problems Pin
Zac Howland30-May-06 9:41
Zac Howland30-May-06 9:41 
QuestionRe: Beginner MFC Dialog Problems Pin
Roger Stoltz30-May-06 5:53
Roger Stoltz30-May-06 5:53 
QuestionPOP3 server source Pin
Arman S.30-May-06 5:30
Arman S.30-May-06 5:30 
QuestionHow to place an edit box and dialog box on a window in VC++ dot Net Pin
Ashutosh Bagaria30-May-06 5:28
Ashutosh Bagaria30-May-06 5:28 
AnswerRe: How to place an edit box and dialog box on a window in VC++ dot Net Pin
Chris Losinger30-May-06 6:11
professionalChris Losinger30-May-06 6:11 

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.