Karl Blessing
Programmer
I have a very simple windows console app made in VC++ , it's just a small ADO tutorial I'm putting together for a friend, however, with all console apps they exit when they're done, and I've been trying getch() and kbhit() to ask for input then quit, but when I do this, I get no display until After I press a key, heres the code.
the whole *.cpp file so you know what's included etc
[tt]
#include "stdafx.h"
#include "iostream.h"
#include "conio.h"
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" rename_namespace("ADOCG" rename("EOF","EndOfFile"
using namespace ADOCG;
char* FieldToChar(_RecordsetPtr recset, _variant_t Fieldname);
//declares the prototype of the function that will grab the value for a feidl in the current record
//It's a function I created to make the process a little easier.
_ConnectionPtr m_pConnection;
_RecordsetPtr m_pRecordSet;
void main(int argc, char* argv[])
{
::CoInitialize(NULL);
m_pConnection.CreateInstance( __uuidof(Connection) );
m_pRecordSet.CreateInstance( __uuidof(Recordset) );
m_pConnection->Open(L"DSN=ldap", L"", L"", -1);
m_pRecordSet->Open( "Select * from MyTable", m_pConnection.GetInterfacePtr(), adOpenDynamic, adLockOptimistic, adCmdText );
if (!m_pRecordSet->EndOfFile)
{
do
{
cout<<FieldToChar(m_pRecordSet,L"f1"<<" - ";
cout<<FieldToChar(m_pRecordSet,L"f2"<<'\n';
m_pRecordSet->MoveNext();
}while (!m_pRecordSet->EndOfFile);
}
m_pRecordSet->Close();
::CoUninitialize();
cout<<"\nPress Enter to Exit";
while(!kbhit());
}
char* FieldToChar(_RecordsetPtr recset, _variant_t Fieldname)
{
_variant_t tmpvariant; char tmpChar[255];
tmpvariant = recset->GetCollect(Fieldname);
strcpy(tmpChar,(_bstr_t)tmpvariant);
return (tmpChar);
}
[/tt]
some insight on this is greatly appreciated. LOL [sig]<p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
[/sig]
the whole *.cpp file so you know what's included etc
[tt]
#include "stdafx.h"
#include "iostream.h"
#include "conio.h"
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" rename_namespace("ADOCG" rename("EOF","EndOfFile"
using namespace ADOCG;
char* FieldToChar(_RecordsetPtr recset, _variant_t Fieldname);
//declares the prototype of the function that will grab the value for a feidl in the current record
//It's a function I created to make the process a little easier.
_ConnectionPtr m_pConnection;
_RecordsetPtr m_pRecordSet;
void main(int argc, char* argv[])
{
::CoInitialize(NULL);
m_pConnection.CreateInstance( __uuidof(Connection) );
m_pRecordSet.CreateInstance( __uuidof(Recordset) );
m_pConnection->Open(L"DSN=ldap", L"", L"", -1);
m_pRecordSet->Open( "Select * from MyTable", m_pConnection.GetInterfacePtr(), adOpenDynamic, adLockOptimistic, adCmdText );
if (!m_pRecordSet->EndOfFile)
{
do
{
cout<<FieldToChar(m_pRecordSet,L"f1"<<" - ";
cout<<FieldToChar(m_pRecordSet,L"f2"<<'\n';
m_pRecordSet->MoveNext();
}while (!m_pRecordSet->EndOfFile);
}
m_pRecordSet->Close();
::CoUninitialize();
cout<<"\nPress Enter to Exit";
while(!kbhit());
}
char* FieldToChar(_RecordsetPtr recset, _variant_t Fieldname)
{
_variant_t tmpvariant; char tmpChar[255];
tmpvariant = recset->GetCollect(Fieldname);
strcpy(tmpChar,(_bstr_t)tmpvariant);
return (tmpChar);
}
[/tt]
some insight on this is greatly appreciated. LOL [sig]<p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
[/sig]