Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple problem

Status
Not open for further replies.

Karl Blessing

Programmer
Feb 25, 2000
2,936
0
0
US
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&quot;f1&quot;)<<&quot; - &quot;;
cout<<FieldToChar(m_pRecordSet,L&quot;f2&quot;)<<'\n';
m_pRecordSet->MoveNext();
}while (!m_pRecordSet->EndOfFile);
}
m_pRecordSet->Close();
::CoUninitialize();

cout<<&quot;\nPress Enter to Exit&quot;;
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]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top