Click here to Skip to main content
15,917,329 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionhow to create Magic packet Pin
rohit.dhamija13-Feb-03 1:04
rohit.dhamija13-Feb-03 1:04 
Questionis there any way to get the facename from a TTF file ? Pin
adara13-Feb-03 0:56
adara13-Feb-03 0:56 
AnswerRe: is there any way to get the facename from a TTF file ? Pin
Chris Losinger13-Feb-03 5:41
professionalChris Losinger13-Feb-03 5:41 
GeneralRe: is there any way to get the facename from a TTF file ? Pin
adara22-Feb-03 20:09
adara22-Feb-03 20:09 
GeneralHiding a running app from task manager Pin
WilliamD13-Feb-03 0:49
WilliamD13-Feb-03 0:49 
GeneralWhere can I learn to create my own control? (mfc) Pin
Rewbs13-Feb-03 0:38
Rewbs13-Feb-03 0:38 
GeneralRe: Where can I learn to create my own control? (mfc) Pin
Anonymous13-Feb-03 1:31
Anonymous13-Feb-03 1:31 
GeneralSimple ADO question Pin
Willem B13-Feb-03 0:00
Willem B13-Feb-03 0:00 
It doesn't work....
I make a ADO connection with my database in my app:

myapp.cpp:<small><br />
// initialisation/constructor<br />
void CMyApp::CMyApp()<br />
{<br />
<br />
try	<br />
	{<br />
		HRESULT hr = m_pConn.CreateInstance (__uuidof (Connection));<br />
<br />
		if (FAILED (hr))<br />
		{<br />
			AfxMessageBox ("Can't create intance of Connection");<br />
		}<br />
		<br />
		if (FAILED (m_pConn->Open (_bstr_t ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = Database.mdb"),<br />
					_bstr_t (""), _bstr_t (""), adModeUnknown)))<br />
		{<br />
			AfxMessageBox ("Can't open datasource");<br />
		}<br />
	}<br />
	catch ( _com_error &e )<br />
	{<br />
		_bstr_t bstrSource (e.Source());<br />
		_bstr_t bstrDescription (e.Description());<br />
		TRACE ( "Exception thrown for classes generated by #import" );<br />
		TRACE ( "\tCode = %08lx\n", e.Error ());<br />
		TRACE ( "\tCode meaning = %s\n", e.ErrorMessage ());<br />
		TRACE ( "\tSource = %s\n", (LPCTSTR) bstrSource);<br />
		TRACE ( "\tDescription = %s\n", (LPCTSTR) bstrDescription);<br />
<br />
		AfxMessageBox ((LPCTSTR) bstrDescription);<br />
	}<br />
	catch (...)<br />
	{<br />
		TRACE ( "*** Unhandled Exception ***" );<br />
	}<br />
<br />
}<br />
</small>

Header file:
myapp.h:<small><br />
	CDatabaseClass AppDatabase;<br />
	_ConnectionPtr m_pConn;<br />
</small><br />


Then i send the pointer(m_pConn) to a new made class and check the database:

myapp.cpp:<small><br />
void CMyApp::CheckLogin()<br />
{<br />
AppDatabase.m_pConn = m_pConn;<br />
if (AppDatabase.CheckLogin(Name, Pass))<br />
{<br />
AfxMessageBox("login correct");<br />
}<br />
}<br />
</small>


Check Function(here it goes wrong):

DatabaseClass.cpp:<small><br />
bool CDatabaseClass::CheckLogin(CString Naam, CString Pass)<br />
{<br />
	bool login;<br />
	try	<br />
	{<br />
		CString tmpNaam, tmpPass;<br />
		<br />
		Naam.Replace("'", " ");<br />
		Pass.Replace("'", " ");<br />
<br />
		login = FALSE;<br />
<br />
		_CommandPtr pCommand;<br />
		pCommand.CreateInstance (__uuidof (Command));<br />
		pCommand->ActiveConnection = m_pConn;<br />
		pCommand->CommandText = "Select * From Gebruikers;";<br />
<br />
		_RecordsetPtr pRecordset;<br />
		pRecordset.CreateInstance (__uuidof (Recordset));<br />
		pRecordset->CursorLocation = adUseClient;<br />
		pRecordset->Open ((IDispatch *) pCommand, vtMissing, adOpenForwardOnly, adLockReadOnly, adCmdUnknown); // Here it goes wrong!!!<br />
		<br />
		while (!pRecordset->GetadoEOF())<br />
		{<br />
			tmpNaam = (char *) (_bstr_t) pRecordset->Fields->GetItem("Naam")->Value;<br />
			tmpPass = (char *) (_bstr_t) pRecordset->Fields->GetItem("Pass")->Value;<br />
<br />
			if {(tmpNaam == Naam) && (tmpPass == Pass)) { login = TRUE; }<br />
<br />
			pRecordset->MoveNext();<br />
		}<br />
<br />
		pRecordset->Close ();<br />
	} <br />
	catch( _com_error &e )<br />
	{<br />
		_bstr_t bstrSource(e.Source());<br />
		_bstr_t bstrDescription(e.Description());<br />
		TRACE( "Exception thrown for classes generated by #import" );<br />
		TRACE( "\tCode = %08lx\n", e.Error());<br />
		TRACE( "\tCode meaning = %s\n", e.ErrorMessage());<br />
		TRACE( "\tSource = %s\n", (LPCTSTR) bstrSource);<br />
		TRACE( "\tDescription = %s\n", (LPCTSTR) bstrDescription);<br />
	}<br />
	catch (...)<br />
	{<br />
		TRACE ( "*** Unhandled Exception ***" );<br />
	}<br />
<br />
	return login;<br />
}<br />
</small>


Well, this doesn't work, the while loop doesn't even get reached. I don't know what i do wrong. Is it possible to send the database pointer around like this?


[]D [] []D []
GeneralATL: fetching messages from other window Pin
peterchen12-Feb-03 23:44
peterchen12-Feb-03 23:44 
GeneralDisable docking of a docking CDialogBar Pin
NeosMatrix12-Feb-03 23:26
NeosMatrix12-Feb-03 23:26 
QuestionHow to set fonts in a control (mfc)? Pin
Jan7512-Feb-03 22:53
Jan7512-Feb-03 22:53 
AnswerRe: How to set fonts in a control (mfc)? Pin
xxhimanshu12-Feb-03 23:20
xxhimanshu12-Feb-03 23:20 
GeneralRe: How to set fonts in a control (mfc)? Pin
Steve S12-Feb-03 23:54
Steve S12-Feb-03 23:54 
GeneralRe: How to set fonts in a control (mfc)? (solving...) Pin
Jan7513-Feb-03 0:13
Jan7513-Feb-03 0:13 
Questiontime scheduling??? Pin
xxhimanshu12-Feb-03 22:49
xxhimanshu12-Feb-03 22:49 
AnswerRe: time scheduling??? Pin
Ted Ferenc13-Feb-03 0:40
Ted Ferenc13-Feb-03 0:40 
GeneralRe: time scheduling??? Pin
xxhimanshu13-Feb-03 1:03
xxhimanshu13-Feb-03 1:03 
GeneralRe: time scheduling??? Pin
Ted Ferenc13-Feb-03 2:04
Ted Ferenc13-Feb-03 2:04 
Generaland STL again... Pin
peterchen12-Feb-03 22:43
peterchen12-Feb-03 22:43 
Generalcalling template member fn (VC6) Pin
peterchen12-Feb-03 21:52
peterchen12-Feb-03 21:52 
GeneralRe: calling template member fn (VC6) Pin
Joan M12-Feb-03 21:59
professionalJoan M12-Feb-03 21:59 
GeneralRe: calling template member fn (VC6) Pin
Joan M12-Feb-03 22:04
professionalJoan M12-Feb-03 22:04 
GeneralRe: calling template member fn (VC6) Pin
peterchen12-Feb-03 22:31
peterchen12-Feb-03 22:31 
Questionconverting wide-character string to float? Pin
Hel12-Feb-03 21:05
Hel12-Feb-03 21:05 
AnswerRe: converting wide-character string to float? Pin
vikramlinux12-Feb-03 21:28
vikramlinux12-Feb-03 21:28 

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.